Trait Array

Source
pub trait Array<K: ArrayKind, T>: Clone {
Show 14 methods // Required methods fn empty() -> Self; fn len(&self) -> K::I; fn from_slice<'a>(slice: K::Slice<'a, T>) -> Self; fn concatenate(&self, other: &Self) -> Self; fn fill(x: T, n: K::I) -> Self; fn get(&self, i: K::I) -> T; fn get_range<R: RangeBounds<K::I>>(&self, rb: R) -> K::Slice<'_, T>; fn set_range<R: RangeBounds<K::I>>(&mut self, rb: R, v: &K::Type<T>); fn gather(&self, idx: K::Slice<'_, K::I>) -> Self; fn scatter(&self, idx: K::Slice<'_, K::I>, n: K::I) -> Self; fn scatter_assign(&mut self, ixs: &K::Index, values: Self); fn scatter_assign_constant(&mut self, ixs: &K::Index, arg: T); // Provided methods fn is_empty(&self) -> bool { ... } fn to_range<R: RangeBounds<K::I>>(&self, r: R) -> Range<K::I> { ... }
}
Expand description

Arrays of elements T for some ArrayKind K.

§Panics

Any operation using an index out of range for the given array will panic.

Required Methods§

Source

fn empty() -> Self

The empty array

Source

fn len(&self) -> K::I

Length of an array

Source

fn from_slice<'a>(slice: K::Slice<'a, T>) -> Self

Source

fn concatenate(&self, other: &Self) -> Self

Concatenate two arrays

Source

fn fill(x: T, n: K::I) -> Self

fill(x, n) returns the array length n containing repeated element x.

Source

fn get(&self, i: K::I) -> T

Retrieve a single element by its index.

Source

fn get_range<R: RangeBounds<K::I>>(&self, rb: R) -> K::Slice<'_, T>

Get a contiguous range of the underlying array as a slice.

Source

fn set_range<R: RangeBounds<K::I>>(&mut self, rb: R, v: &K::Type<T>)

Write to a contiguous range of data in an array

Source

fn gather(&self, idx: K::Slice<'_, K::I>) -> Self

Gather elements of this array according to the indices. https://en.wikipedia.org/wiki/Gather/scatter_(vector_addressing)#Gather

x = self.gather(idx) // equivalent to x[i] = self[idx[i]]
Source

fn scatter(&self, idx: K::Slice<'_, K::I>, n: K::I) -> Self

Scatter elements of self into a new array at indices idx.

x = self.scatter(idx) // equivalent to x[idx[i]] = self[i]
§Panics

If there is any i ≥ n in idx

Source

fn scatter_assign(&mut self, ixs: &K::Index, values: Self)

Source

fn scatter_assign_constant(&mut self, ixs: &K::Index, arg: T)

Numpy self[ixs] = arg

Provided Methods§

Source

fn is_empty(&self) -> bool

Test if an array is empty

Source

fn to_range<R: RangeBounds<K::I>>(&self, r: R) -> Range<K::I>

Clamp any R: RangeBounds<K::I> into the range of valid indices for this array.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Clone> Array<VecKind, T> for VecArray<T>