Module binaryheap
SourceDescription
BinaryHeap — max-heap priority queue.
BinaryHeap elem is a newtype over (Vec elem) — runtime layout matches Vec, but dispatch treats it as a nominally distinct type.
Methods currently panic at runtime; real bodies land once host intrinsics for sift-up / sift-down and heapify arrive. The spec has BinaryHeap implementing Foldable but not Seq, Map, Set, or Indexed, and that wiring is sequenced with the Seq hierarchy work.
Not re-exported by the prelude — use :use :open silo:std.collections.binaryheap ....
Data Types
Types
- BinaryHeap
Max-heap priority queue.
Functions
Functions
- binaryheap-from-vec
Convert a
(Vec elem)to a(BinaryHeap elem).
Trait Implementations
impl BinaryHeap for ?590302
.into-sorted-vec ( (BinaryHeap elem) → (Vec elem) )
.into-sorted-vec ( (BinaryHeap elem) → (Vec elem) )
Consume the heap and return a (Vec elem) in ascending order. O(n log n).
.merge ( (BinaryHeap elem) (BinaryHeap elem) → (BinaryHeap elem) )
.merge ( (BinaryHeap elem) (BinaryHeap elem) → (BinaryHeap elem) )
.merge combines two heaps into a new heap containing every element of both. Duplicates preserved. O(n + m).
.peek-max ( (BinaryHeap elem) → (Option elem) )
.peek-max ( (BinaryHeap elem) → (Option elem) )
.peek-max returns the largest element without removing it. O(1).
.pop-max ( (BinaryHeap elem) → (BinaryHeap elem) (Option elem) )
.pop-max ( (BinaryHeap elem) → (BinaryHeap elem) (Option elem) )
.pop-max removes and returns the largest element, sift-down restores heap invariant. O(log n).
.push ( elem (BinaryHeap elem) → (BinaryHeap elem) )
.push ( elem (BinaryHeap elem) → (BinaryHeap elem) )
.push inserts an element, sift-up restores heap invariant. O(log n). (Ord elem elem) constraint is implicit on the dispatch once the real body lands; stubs skip the bound so the declared-surface tests need no Ord witness.
.to-vec ( (BinaryHeap elem) → (Vec elem) )
.to-vec ( (BinaryHeap elem) → (Vec elem) )
Return a (Vec elem) containing every element without consuming the heap. Order unspecified — in particular, the stub runtime does NOT maintain the max-heap invariant on the backing Vec, so the ordering reflects insertion order rather than heap structure. Callers MUST NOT depend on either heap or sorted ordering here. Runtime identity cast — the backing cell is already a Vec. O(1).