Expand description
A collection of convenience functions for heapifying a slice in rust
.
§Quick Start
A simple way to use heapify
is with a Vec<T>
.
use heapify::*;
let mut vec = vec![5, 7, 9];
make_heap(&mut vec);
pop_heap(&mut vec);
assert_eq!(vec.pop(), Some(9));
pop_heap(&mut vec);
assert_eq!(vec.pop(), Some(7));
assert_eq!(peek_heap(&mut vec), Some(&5));
Structs§
- Heap
Iterator - An iterator type to iterate upon a heap.
- Pred
Heap Iterator - An iterator type to iterate upon a heap with a given predicate.
Functions§
- make_
heap - Transforms the given slice into a maximal heap.
- make_
heap_ iter - Creates a
HeapIterator<T>
from a given slice. - make_
heap_ iter_ with - Creates a
PredHeapIterator<T>
from a given slice and a given predicate. - make_
heap_ with - Transforms the given slice into a heap with a given predicate.
- peek_
heap - Safely peeks at the top element of the heap. Returns
None
if heap is empty. - pop_
heap - Pops an element from a maximal heap.
- pop_
heap_ with - Pops an element from a maximal heap, with a given predicate.
- push_
heap - Pushes an element into a heap.
- push_
heap_ with - Pushes an element into a heap, with a given predicate.