Struct min_max_heap::MinMaxHeap
[−]
[src]
pub struct MinMaxHeap<T>(_);
A double-ended priority queue.
Methods
impl<T> MinMaxHeap<T>
[src]
fn new() -> Self
Creates a new, empty MinMaxHeap
.
fn with_capacity(len: usize) -> Self
Creates a new, empty MinMaxHeap
with space allocated to hold
len
elements.
fn len(&self) -> usize
The number of elements in the heap.
fn is_empty(&self) -> bool
Is the heap empty?
impl<T: Ord> MinMaxHeap<T>
[src]
fn push(&mut self, element: T)
Adds an element to the heap.
fn peek_min(&self) -> Option<&T>
Gets a reference to the minimum element, if any.
fn peek_max(&self) -> Option<&T>
Gets a reference to the maximum element, if any.
fn pop_min(&mut self) -> Option<T>
Removes the minimum element, if any.
fn pop_max(&mut self) -> Option<T>
Removes the maximum element, if any.
fn push_pop_min(&mut self, element: T) -> T
Pushes an element, then pops the minimum element.
Unlike a push followed by a pop, this combined operation will not allocate.
fn push_pop_max(&mut self, element: T) -> T
Pushes an element, then pops the maximum element in an optimized fashion.
Unlike a push followed by a pop, this combined operation will not allocate.
fn replace_min(&mut self, element: T) -> Option<T>
Pops the minimum, then pushes an element in an optimized fashion.
fn replace_max(&mut self, element: T) -> Option<T>
Pops the maximum, then pushes an element in an optimized fashion.
impl<T> MinMaxHeap<T>
[src]
fn clear(&mut self)
Drops all items from the heap.
fn capacity(&self) -> usize
The number of elements the heap can hold without reallocating.
fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for exactly additional
more
elements to be inserted in the given MinMaxHeap
.
Panics
Panics if the new capacity overflows usize
.
fn reserve(&mut self, additional: usize)
Reserves the minimum capacity for at least additional
more
elements to be inserted in the given MinMaxHeap
.
Panics
Panics if the new capacity overflows usize
.
fn shrink_to_fit(&mut self)
Discards extra capacity.
fn into_vec(self) -> Vec<T>
Consumes the MinMaxHeap
and returns its elements in a vector
in arbitrary order.
fn iter(&self) -> Iter<T>
Returns a borrowing iterator over the min-max-heap’s elements in arbitrary order.
fn drain(&mut self) -> Drain<T>
Returns a draining iterator over the min-max-heap’s elements in arbitrary order.
Trait Implementations
impl<T: Debug> Debug for MinMaxHeap<T>
[src]
impl<T: Clone> Clone for MinMaxHeap<T>
[src]
fn clone(&self) -> MinMaxHeap<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T> Default for MinMaxHeap<T>
[src]
impl<'a, T> IntoIterator for &'a MinMaxHeap<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for MinMaxHeap<T>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<T: Ord> FromIterator<T> for MinMaxHeap<T>
[src]
fn from_iter<I>(iter: I) -> Self where I: IntoIterator<Item=T>
Creates a value from an iterator. Read more
impl<T: Ord> Extend<T> for MinMaxHeap<T>
[src]
fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl<'a, T: Ord + Clone + 'a> Extend<&'a T> for MinMaxHeap<T>
[src]
fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more