Struct cranelift::prelude::codegen::entity::EntityMap [−]
A mapping K -> V
for densely indexed entity references.
The EntityMap
data structure uses the dense index space to implement a map with a vector.
Unlike PrimaryMap
, an EntityMap
can't be used to allocate entity references. It is used to
associate secondary information with entities.
The map does not track if an entry for a key has been inserted or not. Instead it behaves as if all keys have a default entry from the beginning.
Methods
impl<K, V> EntityMap<K, V> where
K: EntityRef,
V: Clone,
impl<K, V> EntityMap<K, V> where
K: EntityRef,
V: Clone,
Shared EntityMap
implementation for all value types.
pub fn new() -> EntityMap<K, V> where
V: Default,
pub fn new() -> EntityMap<K, V> where
V: Default,
Create a new empty map.
pub fn with_default(default: V) -> EntityMap<K, V>
pub fn with_default(default: V) -> EntityMap<K, V>
Create a new empty map with a specified default value.
This constructor does not require V to implement Default.
pub fn get(&self, k: K) -> Option<&V>
pub fn get(&self, k: K) -> Option<&V>
Get the element at k
if it exists.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Is this map completely empty?
pub fn clear(&mut self)
pub fn clear(&mut self)
Remove all entries from this map.
ⓘImportant traits for Iter<'a, K, V>pub fn iter(&self) -> Iter<K, V>
pub fn iter(&self) -> Iter<K, V>
Iterate over all the keys and values in this map.
ⓘImportant traits for IterMut<'a, K, V>pub fn iter_mut(&mut self) -> IterMut<K, V>
pub fn iter_mut(&mut self) -> IterMut<K, V>
Iterate over all the keys and values in this map, mutable edition.
ⓘImportant traits for Keys<K>pub fn keys(&self) -> Keys<K>
pub fn keys(&self) -> Keys<K>
Iterate over all the keys in this map.
ⓘImportant traits for Iter<'a, T>pub fn values(&self) -> Iter<V>
pub fn values(&self) -> Iter<V>
Iterate over all the keys in this map.
ⓘImportant traits for IterMut<'a, T>pub fn values_mut(&mut self) -> IterMut<V>
pub fn values_mut(&mut self) -> IterMut<V>
Iterate over all the keys in this map, mutable edition.
pub fn resize(&mut self, n: usize)
pub fn resize(&mut self, n: usize)
Resize the map to have n
entries by adding default entries as needed.
Trait Implementations
impl<K, V> IndexMut<K> for EntityMap<K, V> where
K: EntityRef,
V: Clone,
impl<K, V> IndexMut<K> for EntityMap<K, V> where
K: EntityRef,
V: Clone,
Mutable indexing into an EntityMap
.
The map grows as needed to accommodate new keys.
ⓘImportant traits for &'a mut Rfn index_mut(&mut self, k: K) -> &mut V
fn index_mut(&mut self, k: K) -> &mut V
Performs the mutable indexing (container[index]
) operation.
impl<K, V> Index<K> for EntityMap<K, V> where
K: EntityRef,
V: Clone,
impl<K, V> Index<K> for EntityMap<K, V> where
K: EntityRef,
V: Clone,
Immutable indexing into an EntityMap
.
All keys are permitted. Untouched entries have the default value.
type Output = V
The returned type after indexing.
ⓘImportant traits for &'a mut Rfn index(&self, k: K) -> &V
fn index(&self, k: K) -> &V
Performs the indexing (container[index]
) operation.
impl<K, V> Clone for EntityMap<K, V> where
K: Clone + EntityRef,
V: Clone + Clone,
impl<K, V> Clone for EntityMap<K, V> where
K: Clone + EntityRef,
V: Clone + Clone,
fn clone(&self) -> EntityMap<K, V>
fn clone(&self) -> EntityMap<K, V>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<K, V> Debug for EntityMap<K, V> where
K: Debug + EntityRef,
V: Debug + Clone,
impl<K, V> Debug for EntityMap<K, V> where
K: Debug + EntityRef,
V: Debug + Clone,