Struct radix_heap::RadixHeapMap
source · [−]pub struct RadixHeapMap<K, V> { /* private fields */ }
Expand description
A montone priority queue implemented using a radix heap.
This will be a max-heap.
See the module documentation for more information.
It is a logic error for a key to be modified in such a way that the
item’s ordering relative to any other item, as determined by the Ord
trait, changes while it is in the heap. This is normally only possible
through Cell
, RefCell
, global state, I/O, or unsafe code.
Implementations
sourceimpl<K: Radix + Ord + Copy, V> RadixHeapMap<K, V>
impl<K: Radix + Ord + Copy, V> RadixHeapMap<K, V>
sourcepub fn new() -> RadixHeapMap<K, V>
pub fn new() -> RadixHeapMap<K, V>
Create an empty RadixHeapMap
sourcepub fn new_at(top: K) -> RadixHeapMap<K, V>
pub fn new_at(top: K) -> RadixHeapMap<K, V>
Create an empty RadixHeapMap
with the top key set to a specific
value.
This can be more efficient if you have a known minimum bound of the items being pushed to the heap.
sourcepub fn clear_to(&mut self, top: K)
pub fn clear_to(&mut self, top: K)
Drop all items from the RadixHeapMap
and sets the top key to a
specific value.
This can be more efficient if you have a known maximum bound of the items being pushed to the heap.
sourcepub fn push(&mut self, key: K, value: V)
pub fn push(&mut self, key: K, value: V)
Pushes a new key value pair onto the heap.
Panics
Panics if the key is larger than the current top key.
sourcepub fn pop(&mut self) -> Option<(K, V)>
pub fn pop(&mut self) -> Option<(K, V)>
Remove the greatest element from the heap and returns it, or None
if
empty.
If there is a tie between multiple elements, the last inserted element will be popped first.
This will set the top key to the extracted key.
sourcepub fn top(&self) -> Option<K>
pub fn top(&self) -> Option<K>
The current top value. All keys pushed onto the heap must be smaller than this value.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Discards as much additional capacity as possible.
sourcepub fn iter(&self) -> Iter<'_, K, V>ⓘNotable traits for Iter<'a, K, V>impl<'a, K, V> Iterator for Iter<'a, K, V> type Item = &'a (K, V);
pub fn iter(&self) -> Iter<'_, K, V>ⓘNotable traits for Iter<'a, K, V>impl<'a, K, V> Iterator for Iter<'a, K, V> type Item = &'a (K, V);
Returns an iterator of all key-value pairs in the RadixHeapMap in arbitrary order
Trait Implementations
sourceimpl<K: Clone, V: Clone> Clone for RadixHeapMap<K, V>
impl<K: Clone, V: Clone> Clone for RadixHeapMap<K, V>
sourcefn clone(&self) -> RadixHeapMap<K, V>
fn clone(&self) -> RadixHeapMap<K, V>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<K: Radix + Ord + Copy, V> Default for RadixHeapMap<K, V>
impl<K: Radix + Ord + Copy, V> Default for RadixHeapMap<K, V>
sourcefn default() -> RadixHeapMap<K, V>
fn default() -> RadixHeapMap<K, V>
Returns the “default value” for a type. Read more
sourceimpl<'a, K: Radix + Ord + Copy + 'a, V: Copy + 'a> Extend<&'a (K, V)> for RadixHeapMap<K, V>
impl<'a, K: Radix + Ord + Copy + 'a, V: Copy + 'a> Extend<&'a (K, V)> for RadixHeapMap<K, V>
sourcefn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = &'a (K, V)>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = &'a (K, V)>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<K: Radix + Ord + Copy, V> Extend<(K, V)> for RadixHeapMap<K, V>
impl<K: Radix + Ord + Copy, V> Extend<(K, V)> for RadixHeapMap<K, V>
sourcefn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (K, V)>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<K: Radix + Ord + Copy, V> FromIterator<(K, V)> for RadixHeapMap<K, V>
impl<K: Radix + Ord + Copy, V> FromIterator<(K, V)> for RadixHeapMap<K, V>
sourcefn from_iter<I>(iter: I) -> RadixHeapMap<K, V> where
I: IntoIterator<Item = (K, V)>,
fn from_iter<I>(iter: I) -> RadixHeapMap<K, V> where
I: IntoIterator<Item = (K, V)>,
Creates a value from an iterator. Read more
sourceimpl<K: Radix + Ord + Copy, V> IntoIterator for RadixHeapMap<K, V>
impl<K: Radix + Ord + Copy, V> IntoIterator for RadixHeapMap<K, V>
sourceimpl<'a, K: Radix + Ord + Copy, V> IntoIterator for &'a RadixHeapMap<K, V>
impl<'a, K: Radix + Ord + Copy, V> IntoIterator for &'a RadixHeapMap<K, V>
Auto Trait Implementations
impl<K, V> RefUnwindSafe for RadixHeapMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for RadixHeapMap<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for RadixHeapMap<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for RadixHeapMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for RadixHeapMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more