Skip to main content

ArcArray

Struct ArcArray 

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

Source

pub fn from_owned(arr: Array<T, D>) -> Self

Create an ArcArray from an owned Array.

Source

pub fn shape(&self) -> &[usize]

Shape as a slice.

Source

pub fn ndim(&self) -> usize

Number of dimensions.

Source

pub fn size(&self) -> usize

Total number of elements.

Source

pub fn is_empty(&self) -> bool

Whether the array has zero elements.

Source

pub fn strides(&self) -> &[isize]

Strides as a slice.

Source

pub fn layout(&self) -> MemoryLayout

Memory layout.

Source

pub fn dim(&self) -> &D

Return a reference to the dimension descriptor.

Source

pub fn ref_count(&self) -> usize

Number of shared references to the underlying buffer.

Source

pub fn is_unique(&self) -> bool

Whether this is the sole owner of the data (refcount == 1).

Source

pub fn as_slice(&self) -> &[T]

Get a slice of the data for this array.

Source

pub fn as_ptr(&self) -> *const T

Raw pointer to the first element.

Source

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.

Source

pub fn as_slice_mut(&mut self) -> &mut [T]

Get a mutable slice of the data, performing a CoW clone if necessary.

Source

pub fn mapv_inplace(&mut self, f: impl Fn(T) -> T)

Apply a function to each element, performing CoW if needed.

Source

pub fn into_owned(self) -> Array<T, D>

Convert to an owned Array, cloning if shared.

Source

pub fn copy(&self) -> Self

Deep copy — always creates a new independent buffer.

Source

pub fn flags(&self) -> ArrayFlags

Array flags.

Trait Implementations§

Source§

impl<T: Element, D: Dimension> AsRawBuffer for ArcArray<T, D>

Source§

fn raw_ptr(&self) -> *const u8

Raw pointer to the first element.
Source§

fn raw_shape(&self) -> &[usize]

Shape as a slice of dimension sizes.
Source§

fn raw_strides_bytes(&self) -> Vec<isize>

Strides in bytes (not elements).
Source§

fn raw_dtype(&self) -> DType

Runtime dtype descriptor.
Source§

fn is_c_contiguous(&self) -> bool

Whether the data is C-contiguous.
Source§

fn is_f_contiguous(&self) -> bool

Whether the data is Fortran-contiguous.
Source§

impl<T: Element, D: Dimension> Clone for ArcArray<T, D>

Source§

fn clone(&self) -> Self

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<T: Element, D: Dimension> Debug for ArcArray<T, D>

Source§

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

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

impl<T: Element, D: Dimension> Display for ArcArray<T, D>

Source§

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

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

impl<T: Element, D: Dimension> From<Array<T, D>> for ArcArray<T, D>

Source§

fn from(arr: Array<T, D>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T, D> Freeze for ArcArray<T, D>
where D: Freeze,

§

impl<T, D> RefUnwindSafe for ArcArray<T, D>

§

impl<T, D> Send for ArcArray<T, D>

§

impl<T, D> Sync for ArcArray<T, D>

§

impl<T, D> Unpin for ArcArray<T, D>
where D: Unpin,

§

impl<T, D> UnsafeUnpin for ArcArray<T, D>
where D: UnsafeUnpin,

§

impl<T, D> UnwindSafe for ArcArray<T, D>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.