pub struct CollectingHashMap<K, V, S = RandomState>where
    K: Hash + Eq,
    S: BuildHasher,
{ /* private fields */ }
Expand description

A hashmap that stores a vec of values for each key

Implementations§

Creates a new CollectingHashMap with the default Hasher

Creates a new CollectingHashMap with the given capacity

Creates a new CollectingHashMap using the given HashMap for it’s backing storage

Inserts a value for the given key

If the key is already present, this will append the value to the key’s Vec<V>

Retrieves a reference to a value for the given key

If there is at least one value for the given key, this will return &V using the first element of Ks Vec<V>

Retrieves a mutable reference to a value for the given key

If there is at least one value for the given key, this will return &mut V using the first element of Ks Vec<V>

Retrieves a reference to all values stored for the given key

If there is at least one value present for the given key, this will return a reference to the Vec<V> for the key

Retrieves a mutable reference to all values stored for the given key

If there is at least one value present for the given key, this will return a mutable reference to the Vec<V> for the key

Removes a set of values for the given key

If there is a value present for the given key, this will remove all values from the underlying HashMap but will ONLY return the first element. To return the entire Vec<V> for the key, use remove_all

Removes a set of values for the given key

If there is a value present for the given key, this will remove all values from the underlying HashMap, and return the Vec<V>

The same as HashMap::hasher

The same as HashMap::capacity

The same as HashMap::is_empty

The same as HashMap::reserve

The same as HashMap::keys

The same as HashMap::values

The same as HashMap::values_mut

The same as HashMap::iter

The same as HashMap::iter_mut

The same as HashMap::entry

The same as HashMap::len

The same as HashMap::drain

The same as HashMap::clear

source

pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, Vec<V>)>where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized,

The same as HashMap::retain

Trait Implementations§

Returns the “default value” for a type. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.