pub struct IndexedDomain<T: IndexedValue> { /* private fields */ }
Expand description
An indexed collection of objects.
Contains a reverse-mapping from T
to T::Index
for efficient lookups of indices.
Implementations§
Source§impl<T: IndexedValue> IndexedDomain<T>
impl<T: IndexedValue> IndexedDomain<T>
Sourcepub fn value(&self, index: T::Index) -> &T
pub fn value(&self, index: T::Index) -> &T
Gets the object corresponding to index
.
Panics if index
is not within the domain.
Sourcepub fn index(&self, value: &T) -> T::Index
pub fn index(&self, value: &T) -> T::Index
Gets the index corresponding to value
.
Panics if value
is not within the domain.
Sourcepub fn contains_value(&self, value: &T) -> bool
pub fn contains_value(&self, value: &T) -> bool
Returns true if value
is contained in the domain.
Sourcepub fn contains_index(&self, index: T::Index) -> bool
pub fn contains_index(&self, index: T::Index) -> bool
Returns true if index
is contained in the domain.
Sourcepub fn insert(&mut self, value: T) -> T::Index
pub fn insert(&mut self, value: T) -> T::Index
Adds value
to the domain, returning its new index.
Sourcepub fn as_vec(&self) -> &IndexVec<T::Index, T>
pub fn as_vec(&self) -> &IndexVec<T::Index, T>
Returns immutable access to the underlying indexed vector.
Sourcepub fn ensure(&mut self, value: &T) -> T::Index
pub fn ensure(&mut self, value: &T) -> T::Index
Similar to IndexedDomain::index
, except it adds value
to the domain if it does not exist yet.
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = &T> + ExactSizeIterator<Item = &T>
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = &T> + ExactSizeIterator<Item = &T>
Returns an iterator over all elements of the domain.
Sourcepub fn indices(
&self,
) -> impl DoubleEndedIterator<Item = T::Index> + ExactSizeIterator<Item = T::Index>
pub fn indices( &self, ) -> impl DoubleEndedIterator<Item = T::Index> + ExactSizeIterator<Item = T::Index>
Returns an iterator over all indices of the domain.
Sourcepub fn iter_enumerated(
&self,
) -> impl DoubleEndedIterator<Item = (T::Index, &T)> + ExactSizeIterator<Item = (T::Index, &T)>
pub fn iter_enumerated( &self, ) -> impl DoubleEndedIterator<Item = (T::Index, &T)> + ExactSizeIterator<Item = (T::Index, &T)>
Returns an iterator over all pairs of indices and elements of the domain.
Trait Implementations§
Source§impl<T: Clone + IndexedValue> Clone for IndexedDomain<T>
impl<T: Clone + IndexedValue> Clone for IndexedDomain<T>
Source§fn clone(&self) -> IndexedDomain<T>
fn clone(&self) -> IndexedDomain<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: IndexedValue + Debug> Debug for IndexedDomain<T>
impl<T: IndexedValue + Debug> Debug for IndexedDomain<T>
Source§impl<T: IndexedValue> Default for IndexedDomain<T>
impl<T: IndexedValue> Default for IndexedDomain<T>
Source§impl<T: IndexedValue> From<IndexVec<<T as IndexedValue>::Index, T>> for IndexedDomain<T>
impl<T: IndexedValue> From<IndexVec<<T as IndexedValue>::Index, T>> for IndexedDomain<T>
Source§impl<T: IndexedValue> FromIterator<T> for IndexedDomain<T>
impl<T: IndexedValue> FromIterator<T> for IndexedDomain<T>
Source§fn from_iter<Iter: IntoIterator<Item = T>>(iter: Iter) -> Self
fn from_iter<Iter: IntoIterator<Item = T>>(iter: Iter) -> Self
Creates a value from an iterator. Read more
Auto Trait Implementations§
impl<T> Freeze for IndexedDomain<T>
impl<T> RefUnwindSafe for IndexedDomain<T>
impl<T> Send for IndexedDomain<T>
impl<T> Sync for IndexedDomain<T>
impl<T> Unpin for IndexedDomain<T>
impl<T> UnwindSafe for IndexedDomain<T>
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