Struct tracing_vec::TracingVec [−][src]
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]
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]
&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>
[src]
&mut self,
index: impl Into<TracingIndex>,
val: X
) -> Result<TimedIndex, IndexError>
pub fn insert_after(
&mut self,
index: impl Into<TracingIndex>,
val: X
) -> TimedIndex
[src]
&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>
[src]
&mut self,
index: impl Into<TracingIndex>,
val: X
) -> Result<TimedIndex, IndexError>
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]
&mut self,
index: impl Into<TracingIndex>
) -> Result<TimelessIndex, IndexError>
pub fn replace(
&mut self,
indices: Vec<impl Into<TracingIndex>>,
val: X
) -> Vec<TimelessIndex>
[src]
&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>
[src]
&mut self,
indices: Vec<impl Into<TracingIndex>>,
val: X
) -> Result<Vec<TimelessIndex>, IndexError>
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]
&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>
[src]
&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>
[src]
&mut self,
indices: Vec<impl Into<TracingIndex>>,
f: impl FnOnce(Vec<X>) -> X
) -> Result<TimedIndex, IndexError>
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]
&mut self,
index: impl Into<TracingIndex>
) -> Result<&mut X, IndexError>
impl<X> TracingVec<X>
[src]
pub fn iter(
&self
) -> impl Iterator<Item = &X> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]
&self
) -> impl Iterator<Item = &X> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_mut(
&mut self
) -> impl Iterator<Item = &mut X> + DoubleEndedIterator + ExactSizeIterator
[src]
&mut self
) -> impl Iterator<Item = &mut X> + DoubleEndedIterator + ExactSizeIterator
pub fn indices(
&self
) -> impl Iterator<Item = TimedIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]
&self
) -> impl Iterator<Item = TimedIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_indices(
&self
) -> impl Iterator<Item = (TimedIndex, &X)> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]
&self
) -> impl Iterator<Item = (TimedIndex, &X)> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_mut_indices(
&mut self
) -> impl Iterator<Item = (TimedIndex, &mut X)> + DoubleEndedIterator + ExactSizeIterator
[src]
&mut self
) -> impl Iterator<Item = (TimedIndex, &mut X)> + DoubleEndedIterator + ExactSizeIterator
pub fn timeless_indices(
&self
) -> impl Iterator<Item = TimelessIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
[src]
&self
) -> impl Iterator<Item = TimelessIndex> + DoubleEndedIterator + ExactSizeIterator + Clone
pub fn iter_timeless_indices(
&self
) -> impl Iterator<Item = (TimelessIndex, &X)> + DoubleEndedIterator
[src]
&self
) -> impl Iterator<Item = (TimelessIndex, &X)> + DoubleEndedIterator
pub fn iter_mut_timeless_indices(
&mut self
) -> impl Iterator<Item = (TimelessIndex, &mut X)> + DoubleEndedIterator
[src]
&mut self
) -> impl Iterator<Item = (TimelessIndex, &mut X)> + DoubleEndedIterator
impl<X> TracingVec<X>
[src]
pub fn into_timeless(
&self,
index: impl Into<TracingIndex>
) -> Result<TimelessIndex, IndexError>
[src]
&self,
index: impl Into<TracingIndex>
) -> Result<TimelessIndex, IndexError>
pub fn into_timed(
&self,
index: impl Into<TracingIndex>
) -> Result<TimedIndex, IndexError>
[src]
&self,
index: impl Into<TracingIndex>
) -> Result<TimedIndex, IndexError>
pub fn is_before(
&self,
before: impl Into<TracingIndex>,
after: impl Into<TracingIndex>
) -> Result<bool, IndexError>
[src]
&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>
[src]
&self,
a: impl Into<TracingIndex>,
b: impl Into<TracingIndex>
) -> Result<bool, IndexError>
Trait Implementations
impl<X: Clone> Clone for TracingVec<X>
[src]
fn clone(&self) -> TracingVec<X>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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]
X: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<X> From<Vec<X, Global>> for TracingVec<X>
[src]
impl<X: PartialEq> PartialEq<TracingVec<X>> for TracingVec<X>
[src]
fn eq(&self, other: &TracingVec<X>) -> bool
[src]
fn ne(&self, other: &TracingVec<X>) -> bool
[src]
impl<X> Serialize for TracingVec<X> where
X: Serialize,
[src]
X: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<X> StructuralPartialEq for TracingVec<X>
[src]
Auto Trait Implementations
impl<X> RefUnwindSafe for TracingVec<X> where
X: RefUnwindSafe,
X: RefUnwindSafe,
impl<X> Send for TracingVec<X> where
X: Send,
X: Send,
impl<X> Sync for TracingVec<X> where
X: Sync,
X: Sync,
impl<X> Unpin for TracingVec<X> where
X: Unpin,
X: Unpin,
impl<X> UnwindSafe for TracingVec<X> where
X: UnwindSafe,
X: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,