Struct tracing_vec::TracingVec[][src]

pub struct TracingVec<X> { /* fields omitted */ }

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

impl<X> TracingVec<X>[src]

pub fn new() -> Self[src]

pub unsafe fn from_raw_parts(mem: Vec<X>, snapshots: Vec<Vec<usize>>) -> Self[src]

impl<X> TracingVec<X>[src]

pub fn push(&mut self, val: X)[src]

impl<X> TracingVec<X>[src]

pub fn pop(&mut self) -> Option<TimelessIndex>[src]

pub fn insert_before(
    &mut self,
    index: impl Into<TracingIndex>,
    val: X
) -> TimedIndex
[src]

pub fn try_insert_before(
    &mut self,
    index: impl Into<TracingIndex>,
    val: X
) -> Result<TimedIndex, IndexError>
[src]

pub fn insert_after(
    &mut self,
    index: impl Into<TracingIndex>,
    val: X
) -> TimedIndex
[src]

pub fn try_insert_after(
    &mut self,
    index: impl Into<TracingIndex>,
    val: X
) -> Result<TimedIndex, IndexError>
[src]

pub fn remove(&mut self, index: impl Into<TracingIndex>) -> TimelessIndex[src]

pub fn try_remove(
    &mut self,
    index: impl Into<TracingIndex>
) -> Result<TimelessIndex, IndexError>
[src]

pub fn replace(
    &mut self,
    indices: Vec<impl Into<TracingIndex>>,
    val: X
) -> Vec<TimelessIndex>
[src]

pub fn try_replace(
    &mut self,
    indices: Vec<impl Into<TracingIndex>>,
    val: X
) -> Result<Vec<TimelessIndex>, IndexError>
[src]

impl<X: Clone> TracingVec<X>[src]

pub fn replace_with(
    &mut self,
    indices: Vec<impl Into<TracingIndex>>,
    f: impl FnOnce(Vec<X>) -> X
) -> TimedIndex
[src]

pub fn try_replace_with(
    &mut self,
    indices: Vec<impl Into<TracingIndex>>,
    f: impl FnOnce(Vec<X>) -> X
) -> Result<TimedIndex, IndexError>
[src]

pub fn try_replace_at_last_with(
    &mut self,
    indices: Vec<impl Into<TracingIndex>>,
    f: impl FnOnce(Vec<X>) -> X
) -> Result<TimedIndex, IndexError>
[src]

impl<X> TracingVec<X>[src]

pub fn oldest(&self) -> Vec<&X>[src]

pub fn latest(&self) -> Vec<&X>[src]

pub fn latest_mut(&mut self) -> Vec<&mut X>[src]

pub fn first_index(&self) -> TimedIndex[src]

pub fn try_first_index(&self) -> Option<TimedIndex>[src]

pub fn last_index(&self) -> TimedIndex[src]

pub fn try_last_index(&self) -> Option<TimedIndex>[src]

pub fn len(&self) -> usize[src]

pub fn is_empty(&self) -> bool[src]

pub fn contains(&self, index: impl Into<TracingIndex>) -> bool[src]

Checks if the index points to a valid location within the vector.

pub fn is_alive(&self, index: impl Into<TracingIndex>) -> bool[src]

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>[src]

pub fn get_mut(
    &mut self,
    index: impl Into<TracingIndex>
) -> Result<&mut X, IndexError>
[src]

impl<X> TracingVec<X>[src]

pub fn iter(
    &self
) -> impl Iterator<Item = &X> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]

pub fn iter_mut(
    &mut self
) -> impl Iterator<Item = &mut X> + DoubleEndedIterator + ExactSizeIterator
[src]

pub fn indices(
    &self
) -> impl Iterator<Item = TimedIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]

pub fn iter_indices(
    &self
) -> impl Iterator<Item = (TimedIndex, &X)> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]

pub fn iter_mut_indices(
    &mut self
) -> impl Iterator<Item = (TimedIndex, &mut X)> + DoubleEndedIterator + ExactSizeIterator
[src]

pub fn timeless_indices(
    &self
) -> impl Iterator<Item = TimelessIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]

pub fn iter_timeless_indices(
    &self
) -> impl Iterator<Item = (TimelessIndex, &X)> + DoubleEndedIterator
[src]

pub fn iter_mut_timeless_indices(
    &mut self
) -> impl Iterator<Item = (TimelessIndex, &mut X)> + DoubleEndedIterator
[src]

impl<X> TracingVec<X>[src]

pub fn into_timeless(
    &self,
    index: impl Into<TracingIndex>
) -> Result<TimelessIndex, IndexError>
[src]

pub fn into_timed(
    &self,
    index: impl Into<TracingIndex>
) -> Result<TimedIndex, IndexError>
[src]

pub fn is_before(
    &self,
    before: impl Into<TracingIndex>,
    after: impl Into<TracingIndex>
) -> Result<bool, IndexError>
[src]

pub fn indices_eq(
    &self,
    a: impl Into<TracingIndex>,
    b: impl Into<TracingIndex>
) -> Result<bool, IndexError>
[src]

Trait Implementations

impl<X: Clone> Clone for TracingVec<X>[src]

impl<X: Debug> Debug for TracingVec<X>[src]

impl<X> Default for TracingVec<X>[src]

impl<'de, X> Deserialize<'de> for TracingVec<X> where
    X: Deserialize<'de>, 
[src]

impl<X> From<Vec<X, Global>> for TracingVec<X>[src]

impl<X: PartialEq> PartialEq<TracingVec<X>> for TracingVec<X>[src]

impl<X> Serialize for TracingVec<X> where
    X: Serialize
[src]

impl<X> StructuralPartialEq for TracingVec<X>[src]

Auto Trait Implementations

impl<X> RefUnwindSafe for TracingVec<X> where
    X: RefUnwindSafe

impl<X> Send for TracingVec<X> where
    X: Send

impl<X> Sync for TracingVec<X> where
    X: Sync

impl<X> Unpin for TracingVec<X> where
    X: Unpin

impl<X> UnwindSafe for TracingVec<X> where
    X: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.