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§
source§impl<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> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
Returns an iterator of all key-value pairs in the RadixHeapMap in arbitrary order
Trait Implementations§
source§impl<K: Clone, V: Clone> Clone for RadixHeapMap<K, V>
impl<K: Clone, V: Clone> Clone for RadixHeapMap<K, V>
source§fn clone(&self) -> RadixHeapMap<K, V>
fn clone(&self) -> RadixHeapMap<K, V>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<K: Radix + Ord + Copy, V> Default for RadixHeapMap<K, V>
impl<K: Radix + Ord + Copy, V> Default for RadixHeapMap<K, V>
source§fn default() -> RadixHeapMap<K, V>
fn default() -> RadixHeapMap<K, V>
source§impl<'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>
source§fn 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)>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<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>
source§fn 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)>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)