Struct collecting_hashmap::CollectingHashMap
source · 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§
source§impl<K, V> CollectingHashMap<K, V, RandomState>where
K: Hash + Eq,
impl<K, V> CollectingHashMap<K, V, RandomState>where
K: Hash + Eq,
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>where
K: Hash + Eq,
S: BuildHasher,
impl<K, V, S> CollectingHashMap<K, V, S>where
K: Hash + Eq,
S: BuildHasher,
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>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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 K
s Vec<V>
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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 K
s Vec<V>
sourcepub fn get_all<Q>(&self, key: &Q) -> Option<&Vec<V>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get_all<Q>(&self, key: &Q) -> Option<&Vec<V>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get_all_mut<Q>(&mut self, key: &Q) -> Option<&mut Vec<V>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove_all<Q>(&mut self, key: &Q) -> Option<Vec<V>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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) -> boolwhere
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn contains_key<Q>(&self, k: &Q) -> boolwhere
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
The same as HashMap::contains_key
sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, Vec<V>)>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
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::remove_entry
Trait Implementations§
source§impl<K, V, S> Default for CollectingHashMap<K, V, S>where
K: Hash + Eq,
S: BuildHasher + Default,
impl<K, V, S> Default for CollectingHashMap<K, V, S>where
K: Hash + Eq,
S: BuildHasher + Default,
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>where
K: Hash + Eq,
S: BuildHasher,
impl<K, V, S> Extend<(K, V)> for CollectingHashMap<K, V, S>where
K: Hash + Eq,
S: BuildHasher,
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
)