Struct rust_heap::heap::BoundedBinaryHeap
[−]
[src]
pub struct BoundedBinaryHeap<T> { /* fields omitted */ }
Binary heap with bound
Methods
impl<T: PartialOrd + Clone> BoundedBinaryHeap<T>
[src]
pub fn new(capacity: usize) -> BoundedBinaryHeap<T>
[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());
pub fn from(slice: &[T]) -> BoundedBinaryHeap<T>
[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);
pub fn from_slice_with_capacity(
slice: &[T],
capacity: usize
) -> BoundedBinaryHeap<T>
[src]
slice: &[T],
capacity: usize
) -> BoundedBinaryHeap<T>
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);
pub fn push(&mut self, elem: T) -> Option<T>
[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);
pub fn pop(&mut self) -> Option<T>
[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);
pub fn len(&self) -> usize
[src]
Return the number of elements in the heap
pub fn is_empty(&self) -> bool
[src]
Return true if the heap is empty
pub fn capacity(&self) -> usize
[src]
Return the number of elements the heap can store
pub fn peek(&self) -> Option<&T>
[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,
T: Send,
impl<T> Sync for BoundedBinaryHeap<T> where
T: Sync,
T: Sync,