pub struct TaggedVec<Index, Value> { /* private fields */ }Expand description
A Vec wrapper that allows indexing only via the given Index type.
For actual operation, Index must implement From<usize> and Into<usize>.
Implementations§
Source§impl<Index, Value> TaggedVec<Index, Value>
impl<Index, Value> TaggedVec<Index, Value>
Sourcepub fn push(&mut self, value: Value) -> Index
pub fn push(&mut self, value: Value) -> Index
Inserts the given value at the back of the TaggedVec, returning its index.
Sourcepub fn pop(&mut self) -> Option<(Index, Value)>
pub fn pop(&mut self) -> Option<(Index, Value)>
Removes the value at the back of the TaggedVec and returns it with its index.
Sourcepub fn insert(&mut self, index: Index, value: Value)
pub fn insert(&mut self, index: Index, value: Value)
Inserts the given value at position index, shifting all existing values in range index.. one position to the right.
Sourcepub fn splice<I: IntoIterator<Item = Value>>(
&mut self,
range: impl RangeBounds<Index>,
replace_with: I,
) -> Splice<'_, I::IntoIter>
pub fn splice<I: IntoIterator<Item = Value>>( &mut self, range: impl RangeBounds<Index>, replace_with: I, ) -> Splice<'_, I::IntoIter>
See Vec::splice.
Sourcepub fn retain(&mut self, f: impl FnMut(&Value) -> bool)
pub fn retain(&mut self, f: impl FnMut(&Value) -> bool)
Retains only the values specified by the predicate.
In other words, remove all values v for which f(&v) returns false.
This method operates in place, visiting each value exactly once in the original order, and preserves the order of the retained values.
Sourcepub fn iter(&self) -> impl Iterator<Item = (Index, &Value)>
pub fn iter(&self) -> impl Iterator<Item = (Index, &Value)>
Returns an iterator over references to the entries of the TaggedVec.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (Index, &mut Value)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (Index, &mut Value)>
Returns an iterator over mutable references to the entries of the TaggedVec.
Sourcepub fn iter_values(&self) -> Iter<'_, Value>
pub fn iter_values(&self) -> Iter<'_, Value>
Returns an iterator over references to the values of the TaggedVec.
Sourcepub fn iter_values_mut(&mut self) -> IterMut<'_, Value>
pub fn iter_values_mut(&mut self) -> IterMut<'_, Value>
Returns an iterator over mutable references to the values of the TaggedVec.
Sourcepub fn iter_indices(&self) -> impl Iterator<Item = Index>
pub fn iter_indices(&self) -> impl Iterator<Item = Index>
Returns an iterator over the indices of the TaggedVec.