doc.rust-lang.org
pub struct BinaryHeap<T, A>
A priority queue implemented with a binary heap.
struct
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn append(&mut self, other: &mut Self)
Moves all the elements of other into self, leaving other empty.
method
alloc
Stable since 1.11.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn as_slice(&self) -> &[T]
Returns a slice of all values in the underlying vector, in arbitrary order.
method
alloc
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn capacity(&self) -> usize
Returns the number of elements the binary heap can hold without reallocating.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn clear(&mut self)
Drops all items from the binary heap.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn drain(&mut self) -> Drain<'_, T, A>
Clears the binary heap, returning an iterator over the removed elements in arbitrary order. If the iterator is dropped before being fully consumed, it drops the remaining elements in arbitrary order.
method
alloc
Stable since 1.6.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_sorted_vec(self) -> Vec<T, A>
Consumes the BinaryHeap and returns a vector in sorted (ascending) order.
method
alloc
Stable since 1.5.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_vec(self) -> Vec<T, A>
Consumes the BinaryHeap and returns the underlying vector in arbitrary order.
method
alloc
Stable since 1.5.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn is_empty(&self) -> bool
Checks if the binary heap is empty.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn iter(&self) -> Iter<'_, T>
Returns an iterator visiting all values in the underlying vector, in arbitrary order.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn len(&self) -> usize
Returns the length of the binary heap.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new() -> BinaryHeap<T>
Creates an empty BinaryHeap as a max-heap.
associated_function
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn peek(&self) -> Option<&T>
Returns the greatest item in the binary heap, or None if it is empty.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T, A>>
Returns a mutable reference to the greatest item in the binary heap, or None if it is empty.
method
alloc
Stable since 1.12.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn pop(&mut self) -> Option<T>
Removes the greatest item from the binary heap and returns it, or None if it is empty.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn push(&mut self, item: T)
Pushes an item onto the binary heap.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional elements more than the current length. The allocator may reserve more space to speculatively avoid frequent allocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for at least additional elements more than the current length. Unlike reserve, this will not deliberately over-allocate to speculatively avoid frequent allocations. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
method
alloc
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to(&mut self, min_capacity: usize)
Discards capacity with a lower bound.
method
alloc
Stable since 1.56.0
Version 1.100.0-nightly