pub struct IndexVec<'a, K: IndexedValue + 'a, V, P: PointerFamily<'a>> { /* private fields */ }
Expand description
A fixed-sized vector with one value for each key in the domain.
Implementations§
Source§impl<'a, K, V, P> IndexVec<'a, K, V, P>
impl<'a, K, V, P> IndexVec<'a, K, V, P>
Sourcepub fn from_elem(elem: V, domain: &P::Pointer<IndexedDomain<K>>) -> Self
pub fn from_elem(elem: V, domain: &P::Pointer<IndexedDomain<K>>) -> Self
Constructs a new vector where each index maps to the initial element elem
.
Source§impl<'a, K, V, P> IndexVec<'a, K, V, P>where
K: IndexedValue + 'a,
P: PointerFamily<'a>,
impl<'a, K, V, P> IndexVec<'a, K, V, P>where
K: IndexedValue + 'a,
P: PointerFamily<'a>,
Sourcepub fn from_fn(
f: impl FnMut(K::Index) -> V,
domain: &P::Pointer<IndexedDomain<K>>,
) -> Self
pub fn from_fn( f: impl FnMut(K::Index) -> V, domain: &P::Pointer<IndexedDomain<K>>, ) -> Self
Constructs a new vector where each index maps to the output of f(index)
.
Sourcepub fn get<M>(&self, idx: impl ToIndex<K, M>) -> &V
pub fn get<M>(&self, idx: impl ToIndex<K, M>) -> &V
Returns an immutable reference to a value for a given index.
Sourcepub fn get_mut<M>(&mut self, idx: impl ToIndex<K, M>) -> &mut V
pub fn get_mut<M>(&mut self, idx: impl ToIndex<K, M>) -> &mut V
Returns a mutable reference to a value for a given index.
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = &V> + ExactSizeIterator<Item = &V>
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = &V> + ExactSizeIterator<Item = &V>
Returns an iterator over immutable references to the values.
Sourcepub fn iter_mut(
&mut self,
) -> impl DoubleEndedIterator<Item = &mut V> + ExactSizeIterator<Item = &mut V>
pub fn iter_mut( &mut self, ) -> impl DoubleEndedIterator<Item = &mut V> + ExactSizeIterator<Item = &mut V>
Returns an iterator over mutable references to the values.
Sourcepub fn as_slice_mut(&mut self) -> &mut [V]
pub fn as_slice_mut(&mut self) -> &mut [V]
Returns the underlying vector as a mutable slice.
Sourcepub fn get_disjoint_mut<const N: usize>(
&mut self,
indices: [K::Index; N],
) -> Result<[&mut V; N], GetDisjointMutError>
pub fn get_disjoint_mut<const N: usize>( &mut self, indices: [K::Index; N], ) -> Result<[&mut V; N], GetDisjointMutError>
Returns multiple mutable references to disjoint indices,
or a GetDisjointMutError
if not disjoint or in-bounds.
Trait Implementations§
Source§impl<'a, K, V, P> Index<<K as IndexedValue>::Index> for IndexVec<'a, K, V, P>where
K: IndexedValue + 'a,
P: PointerFamily<'a>,
impl<'a, K, V, P> Index<<K as IndexedValue>::Index> for IndexVec<'a, K, V, P>where
K: IndexedValue + 'a,
P: PointerFamily<'a>,
Source§impl<'a, K, V, P> IndexMut<<K as IndexedValue>::Index> for IndexVec<'a, K, V, P>where
K: IndexedValue + 'a,
P: PointerFamily<'a>,
impl<'a, K, V, P> IndexMut<<K as IndexedValue>::Index> for IndexVec<'a, K, V, P>where
K: IndexedValue + 'a,
P: PointerFamily<'a>,
impl<'a, K, V, P> Eq for IndexVec<'a, K, V, P>
Auto Trait Implementations§
impl<'a, K, V, P> Freeze for IndexVec<'a, K, V, P>
impl<'a, K, V, P> RefUnwindSafe for IndexVec<'a, K, V, P>
impl<'a, K, V, P> Send for IndexVec<'a, K, V, P>
impl<'a, K, V, P> Sync for IndexVec<'a, K, V, P>
impl<'a, K, V, P> Unpin for IndexVec<'a, K, V, P>
impl<'a, K, V, P> UnwindSafe for IndexVec<'a, K, V, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more