Version: 5.1.3
7 Binary Heaps
(require data/heap) |
Binary heaps are a simple implementation of priority queues.
Makes a new empty heap using <=? to order elements.
Returns #t if x is a heap, #f otherwise.
(heap-count h) → exact-nonnegative-integer? |
h : heap? |
Returns the number of elements in the heap.
Adds each v to the heap.
Adds each element contained in v to the heap, leaving
v unchanged.
Returns the least element in the heap h, according to the
heap’s ordering. If the heap is empty, an exception is raised.
(heap-remove-min! h) → void? |
h : heap? |
Removes the least element in the heap h. If the heap is
empty, an exception is raised.
Builds a heap with the elements from items. The vector is not
modified.
(heap->vector h) → vector? |
h : heap? |
Returns a vector containing the elements of heap h in the
heap’s order. The heap is not modified.
Makes a copy of heap h.
Sorts vector v using the comparison function <=?.