minheap

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package minheap provides an interface and implementations for the min heap data structure

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayMinHeap

type ArrayMinHeap[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

func NewArrayMinHeap

func NewArrayMinHeap[T cmp.Ordered](i ...T) *ArrayMinHeap[T]

NewMinHeap instantiates a min heap and returns a pointer to it. The variadic argument can be used to insert items into the heap after it is created.

func (*ArrayMinHeap[T]) Extract

func (m *ArrayMinHeap[T]) Extract() T

Extract returns the minimum item from the min heap and swaps the elements as necessary to restore the heap property in the data structure.

func (*ArrayMinHeap[T]) Insert

func (m *ArrayMinHeap[T]) Insert(i T)

Insert inserts the item into the min heap.

func (*ArrayMinHeap[T]) Peek

func (m *ArrayMinHeap[T]) Peek() T

func (*ArrayMinHeap[T]) Size

func (m *ArrayMinHeap[T]) Size() int

type MinHeap

type MinHeap[T cmp.Ordered] interface {
	Insert(i T)
	Extract() T
	Size() int
	Peek() T
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL