Zafu/Collection/Heapsource code:
public dependencies: Zafu/Abstract/Eq, Zafu/Abstract/Foldable,
Zafu/Abstract/Ord
Heapcombine, combine_assume_same_order,
empty, eq, foldable_Heap, foldl, from_List, insert, is_empty, min, ord, pop_min, singleton, size, to_ListHeap[a]Pairing heap with ordering owned by each heap value.
type Heap[a: *]
combineCombines two heaps. For non-empty heaps this rebuilds the right side under the left ordering to preserve correctness when orderings differ.
references: Heap
def combine[a](heap: Heap[a], other: Heap[a]) -> Heap[a]
combine_assume_same_orderFast O(1) meld for heaps that share the same effective ordering. If orderings differ, results are still memory-safe but may be incorrect.
references: Heap
def combine_assume_same_order[a](heap: Heap[a], other: Heap[a]) -> Heap[a]
emptyEmpty heap for a chosen ordering.
references: Heap, Zafu/Abstract/Ord::Ord
def empty[a](ord: Zafu/Abstract/Ord::Ord[a]) -> Heap[a]
eqreferences: Heap, Zafu/Abstract/Eq::Eq
def eq[a](inst: Zafu/Abstract/Eq::Eq[a]) -> Zafu/Abstract/Eq::Eq[Heap[a]]
foldable_Heapreferences: Heap, Zafu/Abstract/Foldable::Foldable
foldable_Heap: Zafu/Abstract/Foldable::Foldable[Heap]
foldlFold in min-to-max order.
references: Heap
def foldl[a, b](heap: Heap[a], init: b, fn: (b, a) -> b) -> b
from_ListBuilds a heap with pairwise rounds to avoid one-sided insertion chains.
references: Heap, List, Zafu/Abstract/Ord::Ord
def from_List[a](ord: Zafu/Abstract/Ord::Ord[a], items: List[a]) -> Heap[a]
insertInserts one item in O(1) amortized by linking with a singleton root.
references: Heap
def insert[a](heap: Heap[a], item: a) -> Heap[a]
is_emptyTrue if heap has no elements.
def is_empty[a](heap: Heap[a]) -> Bool
minReturns the minimum element, if present.
def min[a](heap: Heap[a]) -> Option[a]
ordreferences: Heap, Zafu/Abstract/Ord::Ord
def ord[a](inst: Zafu/Abstract/Ord::Ord[a]) -> Zafu/Abstract/Ord::Ord[Heap[a]]
pop_minRemove minimum and rebuild remainder via two-pass child pairing.
references: Heap, Option, Tuple2
def pop_min[a](heap: Heap[a]) -> Option[(a, Heap[a])]
singletonSingle-element heap.
references: Heap, Zafu/Abstract/Ord::Ord
def singleton[a](ord: Zafu/Abstract/Ord::Ord[a], item: a) -> Heap[a]
sizeO(1) cached size.
def size[a](heap: Heap[a]) -> Int
to_ListAscending list view from repeated pop_min.
def to_List[a](heap: Heap[a]) -> List[a]