pub struct ArcArray<T: Element, D: Dimension> { /* private fields */ }Expand description
A reference-counted N-dimensional array with copy-on-write semantics.
Multiple ArcArray instances can share the same underlying buffer.
When a mutation is requested and the reference count is greater than 1,
the buffer is cloned first (copy-on-write). Views derived from an
ArcArray observe the data at creation time; subsequent mutations to
the source (which trigger a CoW clone) do not affect existing views.
Implementations§
Source§impl<T: Element, D: Dimension> ArcArray<T, D>
impl<T: Element, D: Dimension> ArcArray<T, D>
Sourcepub fn from_owned(arr: Array<T, D>) -> Self
pub fn from_owned(arr: Array<T, D>) -> Self
Create an ArcArray from an owned Array.
Sourcepub fn layout(&self) -> MemoryLayout
pub fn layout(&self) -> MemoryLayout
Memory layout.
Sourcepub fn view(&self) -> ArrayView<'_, T, D>
pub fn view(&self) -> ArrayView<'_, T, D>
Create an immutable view of the data.
The view borrows from this ArcArray and will see the data as it
exists at creation time. If the ArcArray is later mutated (triggering
a CoW clone), the view continues to see the old data.
Sourcepub fn as_slice_mut(&mut self) -> &mut [T]
pub fn as_slice_mut(&mut self) -> &mut [T]
Get a mutable slice of the data, performing a CoW clone if necessary.
Sourcepub fn mapv_inplace(&mut self, f: impl Fn(T) -> T)
pub fn mapv_inplace(&mut self, f: impl Fn(T) -> T)
Apply a function to each element, performing CoW if needed.
Sourcepub fn into_owned(self) -> Array<T, D>
pub fn into_owned(self) -> Array<T, D>
Convert to an owned Array, cloning if shared.
Sourcepub fn flags(&self) -> ArrayFlags
pub fn flags(&self) -> ArrayFlags
Array flags.