pub struct BinaryHeap<T, C = MaxComparator>where
C: Compare<T>,{
pub data: Vec<T>,
/* private fields */
}
Fields§
§data: Vec<T>
Implementations§
Source§impl<T, C: Compare<T>> BinaryHeap<T, C>
impl<T, C: Compare<T>> BinaryHeap<T, C>
pub fn from_vec_cmp(vec: Vec<T>, cmp: C) -> Self
pub unsafe fn from_vec_cmp_raw(vec: Vec<T>, cmp: C, rebuild: bool) -> Self
Source§impl<T: Ord> BinaryHeap<T>
impl<T: Ord> BinaryHeap<T>
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
Source§impl<T: Ord> BinaryHeap<T, MinComparator>
impl<T: Ord> BinaryHeap<T, MinComparator>
pub fn new_min() -> Self
pub fn with_capacity_min(capacity: usize) -> Self
Source§impl<T, F> BinaryHeap<T, FnComparator<F>>
impl<T, F> BinaryHeap<T, FnComparator<F>>
pub fn new_by(f: F) -> Self
pub fn with_capacity_by(capacity: usize, f: F) -> Self
Source§impl<T, F, K: Ord> BinaryHeap<T, KeyComparator<F>>
impl<T, F, K: Ord> BinaryHeap<T, KeyComparator<F>>
pub fn new_by_key(f: F) -> Self
pub fn with_capacity_by_key(capacity: usize, f: F) -> Self
Source§impl<T, C: Compare<T>> BinaryHeap<T, C>
impl<T, C: Compare<T>> BinaryHeap<T, C>
pub fn replace_cmp(&mut self, cmp: C)
pub unsafe fn replace_cmp_raw(&mut self, cmp: C, rebuild: bool)
pub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn into_iter_sorted(self) -> IntoIterSorted<T, C> ⓘ
pub fn peek(&self) -> Option<&T>
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T, C>>
pub fn capacity(&self) -> usize
pub fn reserve(&mut self, additional: usize)
pub fn shrink_to_fit(&mut self)
pub fn pop(&mut self) -> Option<T>
pub fn push(&mut self, item: T)
pub fn into_vec(self) -> Vec<T>
pub fn into_sorted_vec(self) -> Vec<T>
pub fn sift_up(&mut self, start: usize, pos: usize) -> usize
Sourcepub fn sift_down_range(&mut self, pos: usize, end: usize)
pub fn sift_down_range(&mut self, pos: usize, end: usize)
Take an element at pos
and move it down the heap,
while its children are larger.
pub fn sift_down(&mut self, pos: usize)
Sourcepub fn sift_down_to_bottom(&mut self, pos: usize)
pub fn sift_down_to_bottom(&mut self, pos: usize)
Take an element at pos
and move it all the way down the heap,
then sift it up to its position.
Note: This is faster when the element is known to be large / should be closer to the bottom.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn drain(&mut self) -> Drain<'_, T> ⓘ
pub fn clear(&mut self)
pub fn append(&mut self, other: &mut Self)
Trait Implementations§
Source§impl<T: Ord> Default for BinaryHeap<T>
impl<T: Ord> Default for BinaryHeap<T>
Source§fn default() -> BinaryHeap<T>
fn default() -> BinaryHeap<T>
Returns the “default value” for a type. Read more
Source§impl<'a, T: 'a + Copy, C: Compare<T>> Extend<&'a T> for BinaryHeap<T, C>
impl<'a, T: 'a + Copy, C: Compare<T>> Extend<&'a T> for BinaryHeap<T, C>
Source§fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T, C: Compare<T>> Extend<T> for BinaryHeap<T, C>
impl<T, C: Compare<T>> Extend<T> for BinaryHeap<T, C>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T: Ord> FromIterator<T> for BinaryHeap<T>
impl<T: Ord> FromIterator<T> for BinaryHeap<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'a, T, C: Compare<T>> IntoIterator for &'a BinaryHeap<T, C>
impl<'a, T, C: Compare<T>> IntoIterator for &'a BinaryHeap<T, C>
Auto Trait Implementations§
impl<T, C> Freeze for BinaryHeap<T, C>where
C: Freeze,
impl<T, C> RefUnwindSafe for BinaryHeap<T, C>where
C: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, C> Send for BinaryHeap<T, C>
impl<T, C> Sync for BinaryHeap<T, C>
impl<T, C> Unpin for BinaryHeap<T, C>
impl<T, C> UnwindSafe for BinaryHeap<T, C>where
C: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more