pub struct CollectingHashMap<K, V, S = RandomState>{ /* private fields */ }Expand description
A hashmap that stores a vec of values for each key
Implementations§
Source§impl<K, V> CollectingHashMap<K, V, RandomState>
impl<K, V> CollectingHashMap<K, V, RandomState>
Sourcepub fn new() -> CollectingHashMap<K, V, RandomState>
pub fn new() -> CollectingHashMap<K, V, RandomState>
Creates a new CollectingHashMap with the default Hasher
Sourcepub fn with_capacity(capacity: usize) -> CollectingHashMap<K, V, RandomState>
pub fn with_capacity(capacity: usize) -> CollectingHashMap<K, V, RandomState>
Creates a new CollectingHashMap with the given capacity
Source§impl<K, V, S> CollectingHashMap<K, V, S>
impl<K, V, S> CollectingHashMap<K, V, S>
Sourcepub fn with_hashmap(h: HashMap<K, Vec<V>, S>) -> CollectingHashMap<K, V, S>
pub fn with_hashmap(h: HashMap<K, Vec<V>, S>) -> CollectingHashMap<K, V, S>
Creates a new CollectingHashMap using the given HashMap for it’s backing storage
Sourcepub fn insert(&mut self, k: K, v: V)
pub fn insert(&mut self, k: K, v: V)
Inserts a value for the given key
If the key is already present, this will append the value to the key’s Vec<V>
Sourcepub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get<Q>(&self, key: &Q) -> Option<&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>
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut 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>
Sourcepub fn get_all<Q>(&self, key: &Q) -> Option<&Vec<V>>
pub fn get_all<Q>(&self, key: &Q) -> Option<&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
Sourcepub fn get_all_mut<Q>(&mut self, key: &Q) -> Option<&mut Vec<V>>
pub fn get_all_mut<Q>(&mut self, key: &Q) -> Option<&mut Vec<V>>
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
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
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
Sourcepub fn remove_all<Q>(&mut self, key: &Q) -> Option<Vec<V>>
pub fn remove_all<Q>(&mut self, key: &Q) -> Option<Vec<V>>
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>
Sourcepub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
The same as HashMap::hasher
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
The same as HashMap::capacity
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
The same as HashMap::is_empty
Sourcepub fn reserve(&mut self, amt: usize)
pub fn reserve(&mut self, amt: usize)
The same as HashMap::reserve
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
The same as HashMap::shrink_to_fit
Sourcepub fn keys(&self) -> Keys<'_, K, Vec<V>>
pub fn keys(&self) -> Keys<'_, K, Vec<V>>
The same as HashMap::keys
Sourcepub fn values(&self) -> Values<'_, K, Vec<V>>
pub fn values(&self) -> Values<'_, K, Vec<V>>
The same as HashMap::values
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, Vec<V>>
pub fn values_mut(&mut self) -> ValuesMut<'_, K, Vec<V>>
The same as HashMap::values_mut
Sourcepub fn iter(&self) -> Iter<'_, K, Vec<V>>
pub fn iter(&self) -> Iter<'_, K, Vec<V>>
The same as HashMap::iter
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, Vec<V>>
pub fn iter_mut(&mut self) -> IterMut<'_, K, Vec<V>>
The same as HashMap::iter_mut
Sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, Vec<V>>
pub fn entry(&mut self, key: K) -> Entry<'_, K, Vec<V>>
The same as HashMap::entry
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The same as HashMap::len
Sourcepub fn drain(&mut self) -> Drain<'_, K, Vec<V>>
pub fn drain(&mut self) -> Drain<'_, K, Vec<V>>
The same as HashMap::drain
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
The same as HashMap::clear
Sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
The same as HashMap::contains_key
Sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, Vec<V>)>
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, Vec<V>)>
The same as HashMap::remove_entry
Trait Implementations§
Source§impl<K, V, S> Default for CollectingHashMap<K, V, S>
impl<K, V, S> Default for CollectingHashMap<K, V, S>
Source§fn default() -> CollectingHashMap<K, V, S>
fn default() -> CollectingHashMap<K, V, S>
Source§impl<K, V, S> Extend<(K, V)> for CollectingHashMap<K, V, S>
impl<K, V, S> Extend<(K, V)> for CollectingHashMap<K, V, S>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
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)