pub struct DenseMapCollection<K: DenseMapCollectionKey, T> { /* private fields */ }
Expand description
A generic collection indexed by a DenseMapCollectionKey
.
DenseMapCollection
provides the same performance guarantees as DenseMap
, but
provides a two-level keying scheme that matches the pattern used in
[crate::DeviceDense
].
Implementations§
Source§impl<K: DenseMapCollectionKey, T> DenseMapCollection<K, T>
impl<K: DenseMapCollectionKey, T> DenseMapCollection<K, T>
Sourcepub fn get(&self, key: &K) -> Option<&T>
pub fn get(&self, key: &K) -> Option<&T>
Returns a reference to the item indexed by key
, or None
if the key
doesn’t exist.
Sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut T>
pub fn get_mut(&mut self, key: &K) -> Option<&mut T>
Returns a mutable reference to the item indexed by key
, or None
if
the key
doesn’t exist.
Sourcepub fn remove(&mut self, key: &K) -> Option<T>
pub fn remove(&mut self, key: &K) -> Option<T>
Removes item indexed by key
from the container.
Returns the removed item if it exists, or None
otherwise.
Sourcepub fn insert(&mut self, key: &K, item: T) -> Option<T>
pub fn insert(&mut self, key: &K, item: T) -> Option<T>
Inserts item
at key
.
If the DenseMapCollection
already contained an item indexed by key
,
insert
returns it, or None
otherwise.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = &T>
pub fn iter(&self) -> impl ExactSizeIterator<Item = &T>
Creates an iterator over the containing items.
Sourcepub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = &mut T>
Creates a mutable iterator over the containing items.
Sourcepub fn iter_maps(&self) -> impl Iterator<Item = &DenseMap<T>>
pub fn iter_maps(&self) -> impl Iterator<Item = &DenseMap<T>>
Creates an iterator over the maps in variant order.
Sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, T>
pub fn entry(&mut self, key: K) -> Entry<'_, K, T>
Gets the given key’s corresponding entry in the map for in-place manipulation.
Sourcepub fn push_entry(
&mut self,
make_key: fn(_: usize) -> K,
value: T,
) -> OccupiedEntry<'_, K, T>
pub fn push_entry( &mut self, make_key: fn(_: usize) -> K, value: T, ) -> OccupiedEntry<'_, K, T>
Inserts a new entry, constructing a key with the provided function.
§Panics
The make_key
function must always construct keys of the same
variant, otherwise this method will panic.