Struct min_max_heap::MinMaxHeap
[−]
[src]
pub struct MinMaxHeap<T>(_);
A double-ended priority queue.
Methods
impl<T> MinMaxHeap<T>
[src]
pub fn new() -> Self
[src]
Creates a new, empty MinMaxHeap
.
pub fn with_capacity(len: usize) -> Self
[src]
Creates a new, empty MinMaxHeap
with space allocated to hold
len
elements.
pub fn len(&self) -> usize
[src]
The number of elements in the heap.
pub fn is_empty(&self) -> bool
[src]
Is the heap empty?
impl<T: Ord> MinMaxHeap<T>
[src]
pub fn push(&mut self, element: T)
[src]
Adds an element to the heap.
pub fn peek_min(&self) -> Option<&T>
[src]
Gets a reference to the minimum element, if any.
pub fn peek_max(&self) -> Option<&T>
[src]
Gets a reference to the maximum element, if any.
pub fn pop_min(&mut self) -> Option<T>
[src]
Removes the minimum element, if any.
pub fn pop_max(&mut self) -> Option<T>
[src]
Removes the maximum element, if any.
pub fn push_pop_min(&mut self, element: T) -> T
[src]
Pushes an element, then pops the minimum element.
Unlike a push followed by a pop, this combined operation will not allocate.
pub fn push_pop_max(&mut self, element: T) -> T
[src]
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.
pub fn replace_min(&mut self, element: T) -> Option<T>
[src]
Pops the minimum, then pushes an element in an optimized fashion.
pub fn replace_max(&mut self, element: T) -> Option<T>
[src]
Pops the maximum, then pushes an element in an optimized fashion.
pub fn into_vec_asc(self) -> Vec<T>
[src]
Returns an ascending (sorted) vector, reusing the heap’s storage.
pub fn into_vec_desc(self) -> Vec<T>
[src]
Returns an descending (sorted) vector, reusing the heap’s storage.
impl<T> MinMaxHeap<T>
[src]
pub fn clear(&mut self)
[src]
Drops all items from the heap.
pub fn capacity(&self) -> usize
[src]
The number of elements the heap can hold without reallocating.
pub fn reserve_exact(&mut self, additional: usize)
[src]
Reserves the minimum capacity for exactly additional
more
elements to be inserted in the given MinMaxHeap
.
Panics
Panics if the new capacity overflows usize
.
pub fn reserve(&mut self, additional: usize)
[src]
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
.
pub fn shrink_to_fit(&mut self)
[src]
Discards extra capacity.
pub fn into_vec(self) -> Vec<T>
[src]
Consumes the MinMaxHeap
and returns its elements in a vector
in arbitrary order.
ⓘImportant traits for Iter<'a, T>pub fn iter(&self) -> Iter<T>
[src]
Returns a borrowing iterator over the min-max-heap’s elements in arbitrary order.
ⓘImportant traits for Drain<'a, T>pub fn drain(&mut self) -> Drain<T>
[src]
Returns a draining iterator over the min-max-heap’s elements in arbitrary order.
Trait Implementations
impl<T: Clone> Clone for MinMaxHeap<T>
[src]
fn clone(&self) -> MinMaxHeap<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for MinMaxHeap<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. 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
[src]
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
[src]
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>,
[src]
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
impl<T: Ord> From<Vec<T>> for MinMaxHeap<T>
[src]
impl<T: Ord> Extend<T> for MinMaxHeap<T>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
[src]
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)
[src]
Extends a collection with the contents of an iterator. Read more
Auto Trait Implementations
impl<T> Send for MinMaxHeap<T> where
T: Send,
T: Send,
impl<T> Sync for MinMaxHeap<T> where
T: Sync,
T: Sync,