Struct containers::collections::Heap [−][src]
pub struct Heap<T, Rel: TotalOrderRelation<T> = Core, A: Alloc = NullAllocator> { /* fields omitted */ }
Growable heap in terms of Vec
Methods
impl<T, Rel: TotalOrderRelation<T>, A: Alloc> Heap<T, Rel, A>[src]
impl<T, Rel: TotalOrderRelation<T>, A: Alloc> Heap<T, Rel, A>pub fn new_in(a: A, rel: Rel, arity: usize) -> Self[src]
pub fn new_in(a: A, rel: Rel, arity: usize) -> SelfMake a new heap.
pub fn with_capacity_in(
a: A,
rel: Rel,
arity: usize,
cap: usize
) -> Option<Self>[src]
pub fn with_capacity_in(
a: A,
rel: Rel,
arity: usize,
cap: usize
) -> Option<Self>Make a new heap with enough room to hold at least cap elements.
Failures
Returns None if allocation fails.
pub fn arity(&self) -> usize[src]
pub fn arity(&self) -> usizeReturn arity.
pub fn length(&self) -> usize[src]
pub fn length(&self) -> usizeReturn number of elements in heap.
pub fn capacity(&self) -> usize[src]
pub fn capacity(&self) -> usizeReturn number of elements heap can hold before reallocation.
pub fn reserve(&mut self, n_more: usize) -> bool[src]
pub fn reserve(&mut self, n_more: usize) -> boolMake sure the heap has enough room for at least n_more more elements, reallocating if need be.
Failures
Returns false if allocation fails, true otherwise.
pub fn from_vec(rel: Rel, arity: usize, v: Vec<T, A>) -> Self[src]
pub fn from_vec(rel: Rel, arity: usize, v: Vec<T, A>) -> SelfBuild a heap of the elements of v.
pub fn push(&mut self, x: T) -> Result<(), T>[src]
pub fn push(&mut self, x: T) -> Result<(), T>Push an element into the heap.
pub fn pop(&mut self) -> Option<T>[src]
pub fn pop(&mut self) -> Option<T>Pop the root element off the heap and return it; return None if heap empty.
pub fn peek(&self) -> Option<&T>[src]
pub fn peek(&self) -> Option<&T>Return a reference to root element, or None if heap empty.
pub fn peek_mut(&mut self) -> Option<&mut T>[src]
pub fn peek_mut(&mut self) -> Option<&mut T>Return a mutable reference to root element, or None if heap empty.
pub fn push_pop(&mut self, x: T) -> T[src]
pub fn push_pop(&mut self, x: T) -> TPops the root and inserts the given value.
xs being empty is an error.
pub fn into_vec(self) -> Vec<T, A>[src]
pub fn into_vec(self) -> Vec<T, A>Return a Vec of elements of heap in unspecified order.
pub fn into_sorted_vec(self) -> Vec<T, A>[src]
pub fn into_sorted_vec(self) -> Vec<T, A>Return a Vec of elements of heap in sorted order.