Struct catalyst_entities::FragMap
source · pub struct FragMap<T> { /* private fields */ }Expand description
Think of it as paralell Vector. Its contents can be accessed by FragRef and FragSlice. It
can produce valid FragRefs that are initially mutable and thread local, and later can be
promoted to shared and immutable. The access complexity is O(1) but involves double
indirection. This structure does bound checks of each access.
Structure is designed to be sent between main and worker thread, worker thread can push new
items and main thread commits them to the FragBase and pulls updates from it.
Implementations§
source§impl<T> FragMap<T>
impl<T> FragMap<T>
sourcepub fn push(&mut self, value: T) -> FragRef<T>
pub fn push(&mut self, value: T) -> FragRef<T>
Returned FragRef is initially mutable and thread local, after calling commit it will be
promoted to shared and immutable.
sourcepub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) -> FragSlice<T>where
I::IntoIter: ExactSizeIterator,
pub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) -> FragSlice<T>where I::IntoIter: ExactSizeIterator,
Analogous to push but handles sequences.
sourcepub fn commit(&mut self, base: &mut FragBase<T>)
pub fn commit(&mut self, base: &mut FragBase<T>)
Freezes the thread local data and makes it shared.
sourcepub fn commit_unique(self, base: &mut FragBase<T>)
pub fn commit_unique(self, base: &mut FragBase<T>)
Freezes the thread local data and makes it shared. Consuming version avoids cloning.
sourcepub fn pull(&mut self, base: &FragBase<T>)
pub fn pull(&mut self, base: &FragBase<T>)
Pulls updates from possibli commited by other FragMaps.
sourcepub fn indexed(
&self,
slice: FragSlice<T>
) -> impl Iterator<Item = (FragRef<T>, &T)> + ExactSizeIterator + DoubleEndedIteratorwhere
T: NoInteriorMutability,
pub fn indexed( &self, slice: FragSlice<T> ) -> impl Iterator<Item = (FragRef<T>, &T)> + ExactSizeIterator + DoubleEndedIteratorwhere T: NoInteriorMutability,
Returns iterator over slice items along with their FragRef.
sourcepub unsafe fn get_unchecked(&self, index: FragRef<T>) -> &T
pub unsafe fn get_unchecked(&self, index: FragRef<T>) -> &T
Safety
The caller must ensure reference is in range of valid memory.
sourcepub unsafe fn gen_unchecked_slice(&self, slice: FragSlice<T>) -> &[T] ⓘ
pub unsafe fn gen_unchecked_slice(&self, slice: FragSlice<T>) -> &[T] ⓘ
Safety
Ensure slice is in range of valid memory.
sourcepub unsafe fn get_unchacked_mut(&mut self, index: FragRef<T>) -> &mut T
pub unsafe fn get_unchacked_mut(&mut self, index: FragRef<T>) -> &mut T
Safety
Ensure slice is not out of bounds and does not capture frozen element.