Crate heapify

Source
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§

HeapIterator
An iterator type to iterate upon a heap.
PredHeapIterator
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.