algo_rs/data_structure/heap/mod.rs
1pub mod binary_heap;
2pub mod max_binary_heap;
3pub mod min_binary_heap;
4
5pub trait Heap<T> {
6 fn push(&mut self, item: T);
7 fn pop(&mut self) -> Option<T>;
8 fn is_empty(&self) -> bool;
9 fn peek(&self) -> Option<&T>;
10}
11
12/// returns true if left and right elements should be swapped
13/// for min_heap fn(1, 2) == false, fn(2, 1) == true
14pub type HeapFn<T> = fn(&T, &T) -> bool;