Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heap ¶
type Heap[T Lessable[T]] struct { // contains filtered or unexported fields }
Heap represents the heap data structure using a flat array to store the elements. It is a wrapper around the standard library's heap.
func (*Heap[T]) Init ¶
func (h *Heap[T]) Init(d []T)
Init establishes the heap invariants required by the other routines in this package. Init is idempotent with respect to the heap invariants and may be called whenever the heap invariants may have been invalidated. The complexity is O(n) where n = h.Len().
func (*Heap[T]) Pop ¶
func (h *Heap[T]) Pop() T
Pop removes and returns the minimum element (according to Less) from the heap. The complexity is O(log n) where n = h.Len(). Pop is equivalent to Remove(h, 0).
func (*Heap[T]) Push ¶
func (h *Heap[T]) Push(x T)
Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Len().