-
Effekt Library
- heap
- Weighted
- internal
- Tree
- Node
- Empty
- mergePairs
- Heap
- empty
- single
- isEmpty
- meld
- insert
- findMinimum
- extract
- exchange
- each
- collectHeap
- heap Jump to source: libraries/common/heap.effekt
- Weighted
[A] (value: A, weight: Double) - internal
- Tree
[A] - Node
(value: A, weight: Double, subheaps: List[Tree[A]]) - Empty
- mergePairs
[A] (heap: Tree[A], heaps: List[Tree[A]]): Tree[A] / {} - Heap
[A] - empty
[A]: Heap[A] / {} - single
[A] (value: A, weight: Double): Heap[A] / {} - isEmpty
[A] (heap: Heap[A]): Bool / {} - meld
[A] (heap1: Heap[A], heap2: Heap[A]): Heap[A] / {} - insert
[A] (heap: Heap[A], value: A, weight: Double): Heap[A] / {} - findMinimum
[A] (heap: Heap[A]): Option[Weighted[A]] / {} - extract
[A] (heap: Heap[A]): Option[Tuple2[Weighted[A], Heap[A]]] / {} - exchange
[A] (heap: Heap[A], value: A, weight: Double): Tuple2[Weighted[A], Heap[A]] / {} - each
[A] (heap: Heap[A]): Unit / {emit[Weighted[A]]} - collectHeap
[A] { stream: => Unit / {emit[Weighted[A]]} }: Heap[A] / {}
Example usage: examples/stdlib/heap
A value together with its priority. Smaller weights come first.
A pairing heap: empty, or a minimal element with its subheaps.
Merge a nonempty list of heaps, given as head and tail, using the two-pass pairing strategy. O(log n) amortized
Persistent min-heap, implemented as a pairing heap.
The empty heap. O(1)
A heap containing exactly one element. O(1)
Check if the heap is empty. O(1)
Merge two heaps. O(1)
Insert a value with the given weight. O(1)
The element with the smallest weight, without removing it. Returns `None()` if the heap is empty. O(1)
Remove the element with the smallest weight, returning it and the remaining heap. Returns `None()` if the heap is empty. O(log n) amortized
Insert the given value and remove the element with the smallest weight. Returns the given value and the unchanged heap if its weight is not larger than all others. O(log n) amortized
Emit all elements in ascending order of weight. O(n log n)
Collect all emitted elements into a heap. O(n)