Skip to main content

StridedBaseArray

Struct StridedBaseArray 

Source
pub struct StridedBaseArray<Data, const NDIM: usize> { /* private fields */ }
Expand description

Array implementation with explicit non-negative strides.

A logical index maps to the storage offset sum(index[axis] * stride[axis]). The layout may contain gaps, but distinct logical indices may not alias.

Implementations§

Source§

impl<Data: DataContainer, const NDIM: usize> StridedBaseArray<Data, NDIM>

Source

pub fn new(data: Data, shape: [usize; NDIM], stride: [usize; NDIM]) -> Self

Combine a data container with a shape and stride.

The container may be longer than the reachable storage span.

§Panics

Panics if NDIM is zero, the computed data requirement exceeds the container length, or two computed logical offsets are equal. Shape/stride arithmetic uses ordinary usize operations, so callers must provide metadata whose products, offsets, and storage span are representable.

Trait Implementations§

Source§

impl<Data: DataContainer, const NDIM: usize> BaseItem for StridedBaseArray<Data, NDIM>

Source§

type Item = <Data as DataContainer>::Item

Item type.
Source§

impl<Data: ContainerType, const NDIM: usize> ContainerType for StridedBaseArray<Data, NDIM>

Source§

type Type = <Data as ContainerType>::Type

The type for the container.
Source§

fn type_as_str(&self) -> &'static str

Returns the type hint for the container as string ref.
Source§

impl<Data: RawAccessDataContainer, const NDIM: usize> RawAccess for StridedBaseArray<Data, NDIM>

Source§

fn data(&self) -> Option<&[Self::Item]>

Get a slice of the complete backing storage. Read more
Source§

impl<Data: MutableRawAccessDataContainer, const NDIM: usize> RawAccessMut for StridedBaseArray<Data, NDIM>

Source§

fn data_mut(&mut self) -> Option<&mut [Self::Item]>

Get a mutable slice of the whole data. Read more
Source§

impl<Data: DataContainer, const NDIM: usize> Shape<NDIM> for StridedBaseArray<Data, NDIM>

Source§

fn shape(&self) -> [usize; NDIM]

Return the shape of the object.
Source§

fn len(&self) -> usize

Return the length, which for n dimension is the product of the dimensions.
Source§

fn is_empty(&self) -> bool

Return true if the array is empty. Read more
Source§

impl<Data: StableRawAccessDataContainer, const NDIM: usize> StableRawAccessMut for StridedBaseArray<Data, NDIM>

Source§

impl<Data, const NDIM: usize> Stride<NDIM> for StridedBaseArray<Data, NDIM>

Source§

fn stride(&self) -> [usize; NDIM]

Return the stride of the object.
Source§

fn memory_layout(&self) -> MemoryLayout
where Self: Shape<NDIM>,

Return the memory layout. Read more
Source§

fn is_contiguous(&self) -> bool
where Self: Shape<NDIM>,

Return true if the array is contiguous in memory. Read more
Source§

impl<Data: DisjointRefDataContainerMut, const NDIM: usize> UnsafeDisjointRandom1DAccessMut for StridedBaseArray<Data, NDIM>

Source§

impl<Data: RefDataContainer, const NDIM: usize> UnsafeRandom1DAccessByRef for StridedBaseArray<Data, NDIM>

Source§

unsafe fn get_1d_unchecked(&self, index: usize) -> &Self::Item

Return a reference to the element at position determined by index. Read more
Source§

impl<Data: ValueDataContainer, const NDIM: usize> UnsafeRandom1DAccessByValue for StridedBaseArray<Data, NDIM>

Source§

unsafe fn get_value_1d_unchecked(&self, index: usize) -> Self::Item

Return the element at position determined by index. Read more
Source§

impl<Data: RefDataContainerMut, const NDIM: usize> UnsafeRandom1DAccessMut for StridedBaseArray<Data, NDIM>

Source§

unsafe fn get_1d_unchecked_mut(&mut self, index: usize) -> &mut Self::Item

Return a mutable reference to the element at position determined by index. Read more
Source§

impl<Data: RefDataContainer, const NDIM: usize> UnsafeRandomAccessByRef<NDIM> for StridedBaseArray<Data, NDIM>

Source§

unsafe fn get_unchecked(&self, multi_index: [usize; NDIM]) -> &Self::Item

Return a reference to the element at position determined by multi_index. Read more
Source§

impl<Data: ValueDataContainer, const NDIM: usize> UnsafeRandomAccessByValue<NDIM> for StridedBaseArray<Data, NDIM>

Source§

unsafe fn get_value_unchecked(&self, multi_index: [usize; NDIM]) -> Self::Item

Return the element at position determined by multi_index. Read more
Source§

impl<Data: RefDataContainerMut, const NDIM: usize> UnsafeRandomAccessMut<NDIM> for StridedBaseArray<Data, NDIM>

Source§

unsafe fn get_unchecked_mut( &mut self, multi_index: [usize; NDIM], ) -> &mut Self::Item

Return a mutable reference to the element at position determined by multi_index. Read more

Auto Trait Implementations§

§

impl<Data, const NDIM: usize> Freeze for StridedBaseArray<Data, NDIM>
where Data: Freeze, [usize; NDIM]: Freeze,

§

impl<Data, const NDIM: usize> RefUnwindSafe for StridedBaseArray<Data, NDIM>

§

impl<Data, const NDIM: usize> Send for StridedBaseArray<Data, NDIM>
where Data: Send, [usize; NDIM]: Send,

§

impl<Data, const NDIM: usize> Sync for StridedBaseArray<Data, NDIM>
where Data: Sync, [usize; NDIM]: Sync,

§

impl<Data, const NDIM: usize> Unpin for StridedBaseArray<Data, NDIM>
where Data: Unpin, [usize; NDIM]: Unpin,

§

impl<Data, const NDIM: usize> UnsafeUnpin for StridedBaseArray<Data, NDIM>
where Data: UnsafeUnpin, [usize; NDIM]: UnsafeUnpin,

§

impl<Data, const NDIM: usize> UnwindSafe for StridedBaseArray<Data, NDIM>
where Data: UnwindSafe, [usize; NDIM]: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<A, Item, const NDIM: usize> MutableArrayImpl<Item, NDIM> for A
where A: RefArrayImpl<Item, NDIM, Item = Item, Item = Item> + UnsafeDisjointRandom1DAccessMut + UnsafeRandomAccessMut<NDIM>,

Source§

impl<A, Item, const NDIM: usize> MutableRawAccessArrayImpl<Item, NDIM> for A
where A: RawAccessArrayImpl<Item, NDIM, Item = Item> + RawAccessMut,

Source§

impl<Item, Mat, const NDIM: usize> RandomAccessByRef<NDIM> for Mat
where Mat: UnsafeRandomAccessByRef<NDIM, Item = Item> + Shape<NDIM>,

Source§

fn get(&self, multi_index: [usize; NDIM]) -> Option<&<Mat as BaseItem>::Item>

Return a reference to the element at position determined by multi_index. If the value is out of bounds None is returned.
Source§

impl<Mat, const NDIM: usize> RandomAccessByValue<NDIM> for Mat
where Mat: UnsafeRandomAccessByValue<NDIM> + Shape<NDIM>,

Source§

fn get_value( &self, multi_index: [usize; NDIM], ) -> Option<<Mat as BaseItem>::Item>

Return the element at position determined by multi_index. If the value is out of bounds None is returned.
Source§

impl<Item, Mat, const NDIM: usize> RandomAccessMut<NDIM> for Mat
where Mat: UnsafeRandomAccessMut<NDIM, Item = Item> + Shape<NDIM>,

Source§

fn get_mut( &mut self, multi_index: [usize; NDIM], ) -> Option<&mut <Mat as BaseItem>::Item>

Return a mutable reference to the element at position determined by multi_index. If the value is out of bounds None is returned.
Source§

impl<A, Item, const NDIM: usize> RawAccessArrayImpl<Item, NDIM> for A
where A: ValueArrayImpl<Item, NDIM, Item = Item> + RawAccess + Stride<NDIM>,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<A, Item, const NDIM: usize> RefArrayImpl<Item, NDIM> for A
where A: ValueArrayImpl<Item, NDIM, Item = Item, Item = Item> + UnsafeRandom1DAccessByRef + UnsafeRandomAccessByRef<NDIM>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<A, Item, const NDIM: usize> ValueArrayImpl<Item, NDIM> for A
where A: UnsafeRandom1DAccessByValue<Item = Item, Item = Item> + UnsafeRandomAccessByValue<NDIM> + Shape<NDIM> + ContainerType,