[−][src]Struct cranelift_entity::SecondaryMap
A mapping K -> V
for densely indexed entity references.
The SecondaryMap
data structure uses the dense index space to implement a map with a vector.
Unlike PrimaryMap
, an SecondaryMap
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> SecondaryMap<K, V> where
K: EntityRef,
V: Clone,
[src]
K: EntityRef,
V: Clone,
Shared SecondaryMap
implementation for all value types.
pub fn new() -> Self where
V: Default,
[src]
V: Default,
Create a new empty map.
pub fn with_capacity(capacity: usize) -> Self where
V: Default,
[src]
V: Default,
Create a new, empty map with the specified capacity.
The map will be able to hold exactly capacity
elements without reallocating.
pub fn with_default(default: V) -> Self
[src]
Create a new empty map with a specified default value.
This constructor does not require V to implement Default.
pub fn capacity(&self) -> usize
[src]
Returns the number of elements the map can hold without reallocating.
pub fn get(&self, k: K) -> Option<&V>
[src]
Get the element at k
if it exists.
pub fn is_empty(&self) -> bool
[src]
Is this map completely empty?
pub fn clear(&mut self)
[src]
Remove all entries from this map.
ⓘImportant traits for Iter<'a, K, V>pub fn iter(&self) -> Iter<K, V>
[src]
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]
Iterate over all the keys and values in this map, mutable edition.
ⓘImportant traits for Keys<K>pub fn keys(&self) -> Keys<K>
[src]
Iterate over all the keys in this map.
pub fn values(&self) -> Iter<V>
[src]
Iterate over all the values in this map.
pub fn values_mut(&mut self) -> IterMut<V>
[src]
Iterate over all the values in this map, mutable edition.
pub fn resize(&mut self, n: usize)
[src]
Resize the map to have n
entries by adding default entries as needed.
Trait Implementations
impl<K: Debug, V: Debug> Debug for SecondaryMap<K, V> where
K: EntityRef,
V: Clone,
[src]
K: EntityRef,
V: Clone,
impl<K, V> PartialEq<SecondaryMap<K, V>> for SecondaryMap<K, V> where
K: EntityRef,
V: Clone + PartialEq,
[src]
K: EntityRef,
V: Clone + PartialEq,
impl<K, V> Eq for SecondaryMap<K, V> where
K: EntityRef,
V: Clone + PartialEq + Eq,
[src]
K: EntityRef,
V: Clone + PartialEq + Eq,
impl<K, V> Index<K> for SecondaryMap<K, V> where
K: EntityRef,
V: Clone,
[src]
K: EntityRef,
V: Clone,
Immutable indexing into an SecondaryMap
.
All keys are permitted. Untouched entries have the default value.
impl<K, V> IndexMut<K> for SecondaryMap<K, V> where
K: EntityRef,
V: Clone,
[src]
K: EntityRef,
V: Clone,
Mutable indexing into an SecondaryMap
.
The map grows as needed to accommodate new keys.
impl<K: Clone, V: Clone> Clone for SecondaryMap<K, V> where
K: EntityRef,
V: Clone,
[src]
K: EntityRef,
V: Clone,
fn clone(&self) -> SecondaryMap<K, V>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<K, V> Unpin for SecondaryMap<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> Send for SecondaryMap<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for SecondaryMap<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> UnwindSafe for SecondaryMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
impl<K, V> RefUnwindSafe for SecondaryMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,