[][src]Struct cranelift_entity::SecondaryMap

pub struct SecondaryMap<K, V> where
    K: EntityRef,
    V: Clone
{ /* fields omitted */ }

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]

Shared SecondaryMap implementation for all value types.

pub fn new() -> Self where
    V: Default
[src]

Create a new empty map.

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 len(&self) -> usize[src]

Returns the number of elements in the underlying vector.

The number is not necessarily the same as the length of the corresponding PrimaryMap.

pub fn get(&self, k: K) -> Option<&V>[src]

Get the element at k if it exists.

pub fn get_default(&self) -> &V[src]

Get the default value.

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]

impl<K, V> Index<K> for SecondaryMap<K, V> where
    K: EntityRef,
    V: Clone
[src]

Immutable indexing into an SecondaryMap.

All keys are permitted. Untouched entries have the default value.

type Output = V

The returned type after indexing.

impl<K, V> IndexMut<K> for SecondaryMap<K, V> where
    K: EntityRef,
    V: Clone
[src]

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]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<K, V> Unpin for SecondaryMap<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> Sync for SecondaryMap<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Send for SecondaryMap<K, V> where
    K: Send,
    V: Send

impl<K, V> RefUnwindSafe for SecondaryMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> UnwindSafe for SecondaryMap<K, V> where
    K: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.