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 remove_multi(&mut self, indices: impl IntoIterator<Item = Index>)
pub fn remove_multi(&mut self, indices: impl IntoIterator<Item = Index>)
Removes the elements at the specified indices, shifting other elements to the left to fill gaps as required.
The provided indices must be sorted.
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = (Index, &Value)> + ExactSizeIterator
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = (Index, &Value)> + ExactSizeIterator
Returns an iterator over references to the entries of the TaggedVec.
Sourcepub fn iter_mut(
&mut self,
) -> impl DoubleEndedIterator<Item = (Index, &mut Value)> + ExactSizeIterator
pub fn iter_mut( &mut self, ) -> impl DoubleEndedIterator<Item = (Index, &mut Value)> + ExactSizeIterator
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 DoubleEndedIterator<Item = Index> + ExactSizeIterator
pub fn iter_indices( &self, ) -> impl DoubleEndedIterator<Item = Index> + ExactSizeIterator
Returns an iterator over the indices of the TaggedVec.
Trait Implementations§
Source§impl<Index, Value> Extend<Value> for TaggedVec<Index, Value>
impl<Index, Value> Extend<Value> for TaggedVec<Index, Value>
Source§fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)