pub struct TracingVec<X> { /* private fields */ }
Expand description
Tracing vector is a vector that manages its history by keeping track of its elements.
§Storage
The elements are held in a common unstructured storage, together with information about their lifetimes.
§Versioning
A tracing vector contains a list of versions, each containing a vector of identifiers which point to the data in storage. When the tracing vector needs to move the elements, it creates a new version encoding the new ordering.
§Comparison with VersionedVec
A tracing vector has two major benefits: it doesn’t need to clone
its contents when it moves
elements, and it can convert a pseudotime reference to an absolute index, even when the
pseudotime is long obsolete.
While a versioned vector cannot do that (since it cannot keep track of the movement of then elements), it has faster lookup: first lookup the version, then the data. A tracing vector has to lookup the version, the ID and then the data. However, if one doesn’t need to support aliasing, one can take a reference to the data itself. This index then performs just one lookup.
Implementations§
Source§impl<X> TracingVec<X>
impl<X> TracingVec<X>
Source§impl<X> TracingVec<X>
impl<X> TracingVec<X>
Source§impl<X> TracingVec<X>
impl<X> TracingVec<X>
pub fn pop(&mut self) -> Option<TimelessIndex>
pub fn insert_before( &mut self, index: impl Into<TracingIndex>, val: X, ) -> TimedIndex
pub fn try_insert_before( &mut self, index: impl Into<TracingIndex>, val: X, ) -> Result<TimedIndex, IndexError>
pub fn insert_after( &mut self, index: impl Into<TracingIndex>, val: X, ) -> TimedIndex
pub fn try_insert_after( &mut self, index: impl Into<TracingIndex>, val: X, ) -> Result<TimedIndex, IndexError>
pub fn remove(&mut self, index: impl Into<TracingIndex>) -> TimelessIndex
pub fn try_remove( &mut self, index: impl Into<TracingIndex>, ) -> Result<TimelessIndex, IndexError>
pub fn replace( &mut self, indices: Vec<impl Into<TracingIndex>>, val: X, ) -> Vec<TimelessIndex>
pub fn try_replace( &mut self, indices: Vec<impl Into<TracingIndex>>, val: X, ) -> Result<Vec<TimelessIndex>, IndexError>
Source§impl<X: Clone> TracingVec<X>
impl<X: Clone> TracingVec<X>
pub fn replace_with( &mut self, indices: Vec<impl Into<TracingIndex>>, f: impl FnOnce(Vec<X>) -> X, ) -> TimedIndex
pub fn try_replace_with( &mut self, indices: Vec<impl Into<TracingIndex>>, f: impl FnOnce(Vec<X>) -> X, ) -> Result<TimedIndex, IndexError>
pub fn try_replace_at_last_with( &mut self, indices: Vec<impl Into<TracingIndex>>, f: impl FnOnce(Vec<X>) -> X, ) -> Result<TimedIndex, IndexError>
Source§impl<X> TracingVec<X>
impl<X> TracingVec<X>
pub fn oldest(&self) -> Vec<&X>
pub fn latest(&self) -> Vec<&X>
pub fn latest_mut(&mut self) -> Vec<&mut X>
pub fn first_index(&self) -> TimedIndex
pub fn try_first_index(&self) -> Option<TimedIndex>
pub fn last_index(&self) -> TimedIndex
pub fn try_last_index(&self) -> Option<TimedIndex>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn contains(&self, index: impl Into<TracingIndex>) -> bool
pub fn contains(&self, index: impl Into<TracingIndex>) -> bool
Checks if the index points to a valid location within the vector.
Sourcepub fn is_alive(&self, index: impl Into<TracingIndex>) -> bool
pub fn is_alive(&self, index: impl Into<TracingIndex>) -> bool
Checks whether or not the value that the index points to is still alive in the latest
snapshot. If the index isn’t valid, this returns false
.
pub fn get(&self, index: impl Into<TracingIndex>) -> Result<&X, IndexError>
pub fn get_mut( &mut self, index: impl Into<TracingIndex>, ) -> Result<&mut X, IndexError>
Source§impl<X> TracingVec<X>
impl<X> TracingVec<X>
pub fn iter( &self, ) -> impl Iterator<Item = &X> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_mut( &mut self, ) -> impl Iterator<Item = &mut X> + DoubleEndedIterator + ExactSizeIterator
pub fn indices( &self, ) -> impl Iterator<Item = TimedIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_indices( &self, ) -> impl Iterator<Item = (TimedIndex, &X)> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_mut_indices( &mut self, ) -> impl Iterator<Item = (TimedIndex, &mut X)> + DoubleEndedIterator + ExactSizeIterator
pub fn timeless_indices( &self, ) -> impl Iterator<Item = TimelessIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_timeless_indices( &self, ) -> impl Iterator<Item = (TimelessIndex, &X)> + DoubleEndedIterator
pub fn iter_mut_timeless_indices( &mut self, ) -> impl Iterator<Item = (TimelessIndex, &mut X)> + DoubleEndedIterator
Source§impl<X> TracingVec<X>
impl<X> TracingVec<X>
pub fn into_timeless( &self, index: impl Into<TracingIndex>, ) -> Result<TimelessIndex, IndexError>
pub fn into_timed( &self, index: impl Into<TracingIndex>, ) -> Result<TimedIndex, IndexError>
pub fn is_before( &self, before: impl Into<TracingIndex>, after: impl Into<TracingIndex>, ) -> Result<bool, IndexError>
pub fn indices_eq( &self, a: impl Into<TracingIndex>, b: impl Into<TracingIndex>, ) -> Result<bool, IndexError>
Trait Implementations§
Source§impl<X: Clone> Clone for TracingVec<X>
impl<X: Clone> Clone for TracingVec<X>
Source§fn clone(&self) -> TracingVec<X>
fn clone(&self) -> TracingVec<X>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more