Struct heap_map::HeapMap

source ·
pub struct HeapMap<K: Hash + Eq + Copy + Debug, V: Eq + Ord + Clone> { /* private fields */ }
Expand description

The HeapMap maintain a max heap along with a hash map to support additional remove and update operations.

Implementations§

source§

impl<K: Hash + Eq + Copy + Debug, V: Eq + Ord + Clone> HeapMap<K, V>

source

pub fn new() -> Self

source

pub fn insert(&mut self, key: &K, value: V) -> Option<V>

Insert a K-V into the HeapMap. Return the old value if key already exist. Return None otherwise.

source

pub fn remove(&mut self, key: &K) -> Option<V>

Remove key from the HeapMap.

source

pub fn update_with<F>(&mut self, key: &K, update_fn: F)
where F: FnMut(&mut V),

In-place update some fields of a node’s value.

source

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

Return the top K-V reference tuple.

source

pub fn pop(&mut self) -> Option<(K, V)>

Pop the top node and return it as a K-V tuple.

source

pub fn get(&self, key: &K) -> Option<&V>

Get the value reference of key.

source

pub fn clear(&mut self)

Clear all key-values of the HeapMap.

source

pub fn is_empty(&self) -> bool

source

pub fn len(&self) -> usize

source

pub fn iter(&self) -> impl Iterator<Item = V> + '_

Trait Implementations§

source§

impl<K: Hash + Eq + Copy + Debug, V: Eq + Ord + Clone> Default for HeapMap<K, V>

source§

fn default() -> Self

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

impl<K, V> MallocSizeOf for HeapMap<K, V>
where K: MallocSizeOf + Hash + Eq + Copy + Debug, V: MallocSizeOf + Eq + Ord + Clone,

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for HeapMap<K, V>

§

impl<K, V> Send for HeapMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for HeapMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for HeapMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for HeapMap<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where 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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V