Skip to main content

Module binary_heap

Module binary_heap 

Source
Expand description

§BinaryHeap

A binary heap generic over any Numeric type. Uses a standard Vec internally for heap operations and materialises to Vec64 at the sorted output boundary.

§NaN handling

NaN values (possible for f32/f64) are accepted but stored separately from the heap region. They accumulate at the tail of the backing array and never participate in heap operations. peek and pop only return real values. into_sorted_vec64 places NaN at the tail of the output.

For integer types, NaN is not possible so the NaN tracking has zero overhead (partial_cmp always returns Some for integers, so the check optimises away).

Inf values participate in ordering naturally.

§Heap ordering

The default is a min-heap. Use new_max() for a max-heap.

into_sorted_vec64 produces the opposite of heap-priority order (min-heap gives descending, max-heap gives ascending). Call .reverse() on the result if you need the other direction.

Structs§

BinaryHeap64
A binary heap of numeric values.

Enums§

HeapOrder
Comparison direction for heap ordering.