heap
Generated by tinox doc
A generic binary heap (Heap<T>) with a pluggable comparator, plus MinHeap<T>/MaxHeap<T> convenience wrappers for the common min/max-priority-queue case.
Min heap
import tinox.core.heap;
class Main
{
fnc main() -> Int32
{
// Heap::new() defaults to a min-heap comparator (a < b).
let h: Heap<Int64> = Heap::new();
Heap::push(h, 5);
Heap::push(h, 1);
Heap::push(h, 3);
println("smallest: " + Heap::peek(h).toString());
println("popped: " + Heap::pop(h).toString());
println("next smallest: " + Heap::peek(h).toString());
return 0;
}
}