indexical::map

Type Alias DenseRefIndexMap

Source
pub type DenseRefIndexMap<'a, K, V> = DenseIndexMap<'a, K, V, RefFamily<'a>>;
Expand description

DenseIndexMap specialized to the RefFamily.

Aliased Type§

struct DenseRefIndexMap<'a, K, V> { /* private fields */ }

Implementations

Source§

impl<'a, K, V, P> DenseIndexMap<'a, K, V, P>
where K: IndexedValue + 'a, P: PointerFamily<'a>,

Source

pub fn new( domain: &P::Pointer<IndexedDomain<K>>, mk_elem: impl FnMut(K::Index) -> V, ) -> Self

Constructs a new map with an initial element of mk_elem(i) for each i in domain.

Source

pub fn get<M>(&self, idx: impl ToIndex<K, M>) -> Option<&V>

Returns an immutable reference to a value for a given key if it exists.

Source

pub fn get_mut<M>(&mut self, idx: impl ToIndex<K, M>) -> Option<&mut V>

Returns a mutable reference to a value for a given key if it exists.

Source

pub unsafe fn get_unchecked<M>(&self, idx: impl ToIndex<K, M>) -> &V

Returns a reference to a value for a given key.

§Safety

This function has undefined behavior if key is not in self.

Source

pub unsafe fn get_unchecked_mut<M>(&mut self, idx: impl ToIndex<K, M>) -> &mut V

Returns a mutable reference to a value for a given key.

§Safety

This function has undefined behavior if key is not in self.

Source

pub fn insert<M>(&mut self, idx: impl ToIndex<K, M>, value: V)

Inserts the key/value pair into self.

Source

pub fn values(&self) -> impl Iterator<Item = &V> + '_

Returns an iterator over the values of the map.

Trait Implementations

Source§

impl<'a, K, V, P, M, U> FromIndexicalIterator<'a, K, P, M, (U, V)> for DenseIndexMap<'a, K, V, P>
where K: IndexedValue + 'a, P: PointerFamily<'a>, U: ToIndex<K, M>,

Source§

fn from_indexical_iter( iter: impl Iterator<Item = (U, V)>, domain: &P::Pointer<IndexedDomain<K>>, ) -> Self

Converts an iterator into a collection within the given domain.
Source§

impl<'a, K, V, P> Index<<K as IndexedValue>::Index> for DenseIndexMap<'a, K, V, P>
where K: IndexedValue + 'a, P: PointerFamily<'a>,

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: K::Index) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, K, V, P> IndexMut<<K as IndexedValue>::Index> for DenseIndexMap<'a, K, V, P>
where K: IndexedValue + 'a, P: PointerFamily<'a>,

Source§

fn index_mut(&mut self, index: K::Index) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more