Struct rust_heap::heap::BoundedBinaryHeap [] [src]

pub struct BoundedBinaryHeap<T> { /* fields omitted */ }

Binary heap with bound

Methods

impl<T: PartialOrd + Clone> BoundedBinaryHeap<T>
[src]

[src]

Constructor, create a new BoundedBinaryHeap with capacity

extern crate rust_heap;
use rust_heap::heap::BoundedBinaryHeap;
let h:BoundedBinaryHeap<i32> = BoundedBinaryHeap::new(3);
assert_eq!(h.capacity(), 3);
assert_eq!(h.len(), 0);
assert!(h.is_empty());

[src]

Constructor, create a new BoundedBinaryHeap from the content of a slice

extern crate rust_heap;
use rust_heap::heap::BoundedBinaryHeap;
let h = BoundedBinaryHeap::from(&[1,2,3,4,5]);
assert_eq!(h.capacity(), 5);
assert_eq!(h.len(), 5);

[src]

Constructor, create a new BoundedBinaryHeap from the content of a slice with given capacity

extern crate rust_heap;
use rust_heap::heap::BoundedBinaryHeap;
let h = BoundedBinaryHeap::from_slice_with_capacity(&[1,2,3], 5);
assert_eq!(h.capacity(), 5);
assert_eq!(h.len(), 3);

[src]

Push a value into heap if value>=root and keep heap structure Overflow and return the smallest element when heap is full

extern crate rust_heap;
use rust_heap::heap::BoundedBinaryHeap;
let mut h = BoundedBinaryHeap::from(&[1,2,3]);
assert_eq!(h.push(4).unwrap(), 1);
assert_eq!(h.len(), 3);

[src]

Pop the smallest value from heap

extern crate rust_heap;
use rust_heap::heap::BoundedBinaryHeap;
let mut h = BoundedBinaryHeap::from(&[3,2,1]);
assert_eq!(h.pop().unwrap(), 1);

[src]

Return the number of elements in the heap

[src]

Return true if the heap is empty

[src]

Return the number of elements the heap can store

[src]

Return the smallest element or None if the heap is empty

Trait Implementations

Auto Trait Implementations

impl<T> Send for BoundedBinaryHeap<T> where
    T: Send

impl<T> Sync for BoundedBinaryHeap<T> where
    T: Sync