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>

source

pub fn new() -> RadixHeapMap<K, V>

Create an empty RadixHeapMap

source

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.

source

pub fn clear(&mut self)

Drops all items form the RadixHeapMap and sets the top key to None.

source

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.

source

pub fn constrain(&mut self)

Sets the top value to the current maximum key value in the heap

source

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.

source

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.

source

pub fn len(&self) -> usize

Returns the number of elements in the heap

source

pub fn is_empty(&self) -> bool

Returns true if there is no elements in the heap

source

pub fn top(&self) -> Option<K>

The current top value. All keys pushed onto the heap must be smaller than this value.

source

pub fn shrink_to_fit(&mut self)

Discards as much additional capacity as possible.

source

pub fn iter(&self) -> Iter<'_, K, V>

Returns an iterator of all key-value pairs in the RadixHeapMap in arbitrary order

source

pub fn keys(&self) -> Keys<'_, K, V>

Returns an iterator of all keys in the RadixHeapMap in arbitrary order

source

pub fn values(&self) -> Values<'_, K, V>

Returns an iterator of all values in the RadixHeapMap in arbitrary order

Trait Implementations§

source§

impl<K: Clone, V: Clone> Clone for RadixHeapMap<K, V>

source§

fn clone(&self) -> RadixHeapMap<K, V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K: Radix + Ord + Copy + Debug, V: Debug> Debug for RadixHeapMap<K, V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<K: Radix + Ord + Copy, V> Default for RadixHeapMap<K, V>

source§

fn default() -> RadixHeapMap<K, V>

Returns the “default value” for a type. Read more
source§

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)>,

Extends a collection with the contents of an iterator. Read more
source§

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)

🔬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<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)>,

Extends a collection with the contents of an iterator. Read more
source§

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)

🔬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<K: Radix + Ord + Copy, V> FromIterator<(K, V)> for RadixHeapMap<K, V>

source§

fn from_iter<I>(iter: I) -> RadixHeapMap<K, V>where I: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
source§

impl<'a, K: Radix + Ord + Copy, V> IntoIterator for &'a RadixHeapMap<K, V>

§

type Item = &'a (K, V)

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: Radix + Ord + Copy, V> IntoIterator for RadixHeapMap<K, V>

§

type Item = (K, V)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.