Struct cranelift_entity::EntityMap [−][src]
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, [src]
impl<K, V> EntityMap<K, V> where
K: EntityRef,
V: Clone, Shared EntityMap implementation for all value types.
pub fn new() -> Self where
V: Default, [src]
pub fn new() -> Self where
V: Default, Create a new empty map.
pub fn with_default(default: V) -> Self[src]
pub fn with_default(default: V) -> SelfCreate 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>[src]
pub fn get(&self, k: K) -> Option<&V>Get the element at k if it exists.
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolIs this map completely empty?
pub fn clear(&mut self)[src]
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>[src]
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>[src]
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>[src]
pub fn keys(&self) -> Keys<K>Iterate over all the keys in this map.
pub fn values(&self) -> Iter<V>[src]
pub fn values(&self) -> Iter<V>Iterate over all the keys in this map.
pub fn values_mut(&mut self) -> IterMut<V>[src]
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)[src]
pub fn resize(&mut self, n: usize)Resize the map to have n entries by adding default entries as needed.
Trait Implementations
impl<K: Debug, V: Debug> Debug for EntityMap<K, V> where
K: EntityRef,
V: Clone, [src]
impl<K: Debug, V: Debug> Debug for EntityMap<K, V> where
K: EntityRef,
V: Clone, fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<K: Clone, V: Clone> Clone for EntityMap<K, V> where
K: EntityRef,
V: Clone, [src]
impl<K: Clone, V: Clone> Clone for EntityMap<K, V> where
K: EntityRef,
V: Clone, fn clone(&self) -> EntityMap<K, V>[src]
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> Index<K> for EntityMap<K, V> where
K: EntityRef,
V: Clone, [src]
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.
fn index(&self, k: K) -> &V[src]
fn index(&self, k: K) -> &VPerforms the indexing (container[index]) operation.
impl<K, V> IndexMut<K> for EntityMap<K, V> where
K: EntityRef,
V: Clone, [src]
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.