[][src]Macro col_macros::bin_heap

macro_rules! bin_heap {
    (for $vec:expr, ins $( $back:expr ),*) => { ... };
    (for $vec:tt ins, $( $back:tt ,)*) => { ... };
    ($($front:expr),*) => { ... };
    ($( $f:tt ,)*) => { ... };
    ($e:literal; $n:literal) => { ... };
    ($e:expr; $n:literal) => { ... };
    ($e:literal; $n:expr) => { ... };
    ($e:expr; $n:expr) => { ... };
}

Construct or upgrade a binary heap of type BinHeap<T> which can be and is an alias to BinaryHeap<T> in the types module.

All collections with a capacity and the push method are accepted.

Examples

#![feature(proc_macro_hygiene)]
use col_macros::bin_heap;
use col_macros::types::BinHeap;

let mut heap = bin_heap![4, 5, 6];
let mut heap2 = { 
    let mut heap1 = BinHeap::new(); 
     
    heap1.push(4);
    heap1.push(5);
    heap1.push(6);
 
    heap1.push(7);
    heap1.push(8);
    heap1.push(9);
    heap1
};
 
bin_heap![for &mut heap, ins 7, 8].push(9); // we still have a mutable reference

assert_eq!(heap.into_sorted_vec(), heap2.into_sorted_vec());