algo-rs 0.1.0

Set of data structures and algorithms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pub mod binary_heap;
pub mod max_binary_heap;
pub mod min_binary_heap;

pub trait Heap<T> {
    fn push(&mut self, item: T);
    fn pop(&mut self) -> Option<T>;
    fn is_empty(&self) -> bool;
    fn peek(&self) -> Option<&T>;
}

/// returns true if left and right elements should be swapped
/// for min_heap fn(1, 2) == false, fn(2, 1) == true
pub type HeapFn<T> = fn(&T, &T) -> bool;