Documentation ¶
Overview ¶
Package dast contains custom data structure and algorithm implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compare ¶
type Compare[T any] interface { // Compare compares the current element with the given one // and returns the [iterop.Ordering]. Compare(T) iterop.Ordering }
Compare describes the required method for a comparator.
type FIFO ¶
type FIFO[T any] struct { // contains filtered or unexported fields }
FIFO is a FIFO list.
type Heap ¶
type Heap[T Compare[T]] []T
Heap implements a binary heap data structure.
WARN: Please call NewHeap otherwise the heap will not be correctly initialized!
func NewHeap ¶
NewHeap returns a new and initialized [Heap[T]] from the given elements.
The time complexity is O(n) where n = len(elems).
func NewHeapWithCap ¶
NewHeapWithCap returns an empty Heap with the given capacity.
func (Heap[T]) CompareAt ¶
CompareAt compares h[a] with h[b] and returns the result. If a or b are out of bounds of h, the method will panic.
func (*Heap[T]) Pop ¶
func (h *Heap[T]) Pop() T
Pop removes and returns the min. element from h. The method panics if no more elements are available in h.
Time complexity: O(log n).