Documentation
¶
Overview ¶
Package heaps provides generic heaps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
Comparator provides the comparison function for a heap. Less should determine whether a should be popped before b.
type Heap ¶
type Heap[C Comparator[T], T any] struct { // contains filtered or unexported fields }
Heap is a generic heap.
func New ¶
func New[C Comparator[T], T any]() *Heap[C, T]
New returns a new heap that uses the given comparator.
func NewMax ¶
func NewMax[T constraints.Ordered]() *Heap[Max[T], T]
NewMax returns a new max-heap of an ordered type by its natural order.
func NewMin ¶
func NewMin[T constraints.Ordered]() *Heap[Min[T], T]
NewMin returns a new min-heap of an ordered type by its natural order.
func (*Heap[C, T]) Pop ¶
func (h *Heap[C, T]) Pop() T
Pop removes and returns the minimal element in h.
type Max ¶
type Max[T constraints.Ordered] struct{}
Max is a comparator that places the maximal value at the top of the heap.
Click to show internal directories.
Click to hide internal directories.