Documentation ¶
Overview ¶
Package maxheap provides an interface and implementations for the max heap data structure
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MaxHeapArray ¶
func NewMaxHeapArray ¶
func NewMaxHeapArray[T cmp.Ordered](i ...T) *MaxHeapArray[T]
NewMaxHeap instantiates a max heap and returns a pointer to it. The variadic argument can be used to insert items into the heap after it is created.
func (*MaxHeapArray[T]) Extract ¶
func (m *MaxHeapArray[T]) Extract() (T, bool)
Extract returns the maximum item from the max heap and swaps the elements as necessary to restore the heap property in the data structure.
func (*MaxHeapArray[T]) Insert ¶
func (m *MaxHeapArray[T]) Insert(i T)
Insert inserts the item into the max heap.
func (*MaxHeapArray[T]) Peek ¶
func (m *MaxHeapArray[T]) Peek() (T, bool)
func (*MaxHeapArray[T]) Size ¶
func (m *MaxHeapArray[T]) Size() int
Click to show internal directories.
Click to hide internal directories.