Struct TracingVec

Source
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>

Source

pub fn new() -> Self

Source

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

Source§

impl<X> TracingVec<X>

Source

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

Source§

impl<X> TracingVec<X>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl<X: Clone> TracingVec<X>

Source

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

Source

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

Source

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>

Source

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

Source

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

Source

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

Source

pub fn first_index(&self) -> TimedIndex

Source

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

Source

pub fn last_index(&self) -> TimedIndex

Source

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

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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

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

Source

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.

Source

pub fn get(&self, index: impl Into<TracingIndex>) -> Result<&X, IndexError>

Source

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

Source§

impl<X> TracingVec<X>

Source§

impl<X> TracingVec<X>

Source

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

Source

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

Source

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

Source

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>

Source§

fn clone(&self) -> TracingVec<X>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<X: Debug> Debug for TracingVec<X>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<X> Default for TracingVec<X>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<X> From<Vec<X>> for TracingVec<X>

Source§

fn from(mem: Vec<X>) -> Self

Converts to this type from the input type.
Source§

impl<X: PartialEq> PartialEq for TracingVec<X>

Source§

fn eq(&self, other: &TracingVec<X>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<X> Serialize for TracingVec<X>
where X: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<X> StructuralPartialEq for TracingVec<X>

Auto Trait Implementations§

§

impl<X> Freeze for TracingVec<X>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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