Skip to main content

ChunkStridedSliceRef

Struct ChunkStridedSliceRef 

Source
pub struct ChunkStridedSliceRef<T, const N: usize>(/* private fields */);
Expand description

Non-owning strided view over N interleaved lanes in a flat buffer.

ChunkStridedSliceRef<T, N> presents N parallel lanes of T values that step through memory with a common stride. It is the N-lane analogue of StridedSliceRef: element (i, j) lives at base + i * stride + offsets[j].

This type is #[repr(transparent)] over its internal ChunkStrideParts, so it can be safely constructed via pointer casts inside ChunkStridedSliceBase.

Implementations§

Source§

impl<T, const N: usize> ChunkStridedSliceRef<T, N>

Source

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

Return a const pointer to the base element of this view.

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Return a mut pointer to the base element of this view.

Source

pub fn len(&self) -> usize

Number of positions (rows) in the view. Each position holds N elements.

Source

pub fn is_empty(&self) -> bool

Whether or not this chunk of strided slices has any elements.

Source

pub fn get(&self, (i0, i1): (usize, usize)) -> Option<&T>

Return a reference to element (i0, i1), or None if either index is out of bounds.

Source

pub unsafe fn get_unchecked(&self, (i0, i1): (usize, usize)) -> &T

Return a reference to element (i0, i1) without bounds checking.

§Safety

i0 < self.len() and i1 < N must both hold.

Source

pub fn get_mut(&mut self, (i0, i1): (usize, usize)) -> Option<&mut T>

Return a mutable reference to element (i0, i1), or None if either index is out of bounds.

Source

pub unsafe fn get_unchecked_mut(&mut self, (i0, i1): (usize, usize)) -> &mut T

Return a mutable reference to element (i0, i1) without bounds checking.

§Safety

i0 < self.len() and i1 < N must both hold.

Source

pub fn is_chunk_contiguous(&self) -> bool

Return true if the N elements at each position are stored at consecutive addresses.

Source

pub fn is_contiguous(&self) -> bool

Return true if both the inter-position stride equals N and the chunk is contiguous, meaning the entire view is a flat &[[T; N]].

Source

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

Return the chunks’s data as a slice, if it represents a contiguous region of memory. Return None otherwise.

Source

pub fn as_slices(&self) -> Option<[&[T]; N]>

Return the chunks’s data as an array of slices, if each slice represents a contiguous region of memory. Return None otherwise.

Source

pub fn as_mut_slices(&mut self) -> Option<[&mut [T]; N]>

Return the mutable chunks’s data as an array of mutable slices, if each slice represents a contiguous region of memory. Return None otherwise.

Source

pub fn as_mut_slice(&mut self) -> Option<&mut [T]>

Return the mutable chunks’s data as a mutable slice, if it represents a contiguous region of memory. Return None otherwise.

Source

pub fn as_chunks(&self) -> Option<&[[T; N]]>

Return the chunks’s data as a slice of arrays, if it represents a contiguous region of memory. Return None otherwise.

Source

pub fn as_mut_chunks(&mut self) -> Option<&mut [[T; N]]>

Return the mutable chunks’s data as a mutable slice or arrays, if it represents a contiguous region of memory. Return None otherwise.

Source

pub fn iter(&self) -> Iter<'_, T, N>

Return an iterator that yields N-element arrays at each position.

Source

pub fn try_array_chunks(&self) -> Result<ArrayChunks<'_, T, N>, &'static str>

Return an iterator over &[T; N] slices if the N elements at each position are contiguous, or an error if they are not.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T, N>

Return a mutable iterator that yields N-element arrays at each position.

Source

pub fn try_array_chunks_mut( &mut self, ) -> Result<ArrayChunksMut<'_, T, N>, &'static str>

Return a mutable iterator over &mut [T; N] slices if the N elements at each position are contiguous, or an error if they are not.

Source§

impl<T: Clone, const N: usize> ChunkStridedSliceRef<T, N>

Source

pub fn deinterleave<V>(&self, evens: &mut [V; N], odds: &mut [V; N])
where V: DerefMut<Target = [T]>,

Deinterleave N strided slices into N slices

self presents N interleaved lanes; evens[j] and odds[j] receive the even- and odd-indexed elements of lane j, respectively.

§Panics

Panics if any evens[j].len() != (self.len() + 1) / 2 or odds[j].len() != self.len() / 2.

Source

pub fn deinterleave_arrays(&self, evens: &mut [[T; N]], odds: &mut [[T; N]])

Deinterleave into a slice of arrays.

§Panics

Panics if evens.len() != (self.len() + 1) / 2 or odds.len() != self.len() / 2.

Source

pub fn interleave<V>(&mut self, evens: &[V; N], odds: &[V; N])
where V: Deref<Target = [T]>,

N slices are interleaved into N strided slices.

self presents N lanes; evens[j] and odds[j] are the source of the even- and odd-indexed elements of lane j, respectively.

§Panics

Panics if any evens[j].len() != (self.len() + 1) / 2 or odds[j].len() != self.len() / 2.

Source

pub fn interleave_arrays(&mut self, evens: &[[T; N]], odds: &[[T; N]])

N slices are interleaved into N strided slices.

§Panics

Panics if evens.len() != (self.len() + 1) / 2 or odds.len() != self.len() / 2.

Source

pub fn split<V>(&self, first: &mut [V; N], second: &mut [V; N])
where V: DerefMut<Target = [T]>,

Chunk-strided variant of StridedSliceRef::split: read N lanes from a ChunkStridedSliceRef.

Fills first and second with the head and tail ends, respectively, of the N strided lanes.

§Panics

Panics if first[0].len() + second[0].len() > self.len(), or if not all slices in first have the same length, or if not all slices in second have the same length.

Source

pub fn split_arrays(&self, first: &mut [[T; N]], second: &mut [[T; N]])

Chunk-strided variant of StridedSliceRef::split: read N interleaved lanes from a ChunkStridedSliceRef.

§Panics

Panics if first.len() + second.len() > self.len().

Source

pub fn pour_into<V>(&self, sink: &mut [V; N])
where V: DerefMut<Target = [T]>,

Fill the N slices sink with cloned elements of self.

§Panics

Panics if sink[0].len() > self.len() or if not all slices in sink have the same length.

Source§

impl<T: Clone + Zero, const N: usize> ChunkStridedSliceRef<T, N>

Source

pub fn stack<V>(&mut self, first: &[V; N], second: &[V; N])
where V: Deref<Target = [T]>,

Stack N slices into N strided slices

This is the chunked version of StridedSliceRef::stack

§Panics

Panics if first[0].len() + second[0].len() > self.len(), or if not all slices in first have the same length, or if not all slices in second have the same length.

Source

pub fn stack_arrays(&mut self, first: &[[T; N]], second: &[[T; N]])

Stack arrays of N elements into the strided slice.

§Panics

Panics if first.len() + second.len() > self.len().

Source

pub fn fill_from<V>(&mut self, source: &[V; N])
where V: Deref<Target = [T]>,

Fill the N lanes of self with cloned elements from the N source slices, filling the leftover with zero values.

§Panics

Panics if source[0].len() > self.len() or if not all slices in source have the same length.

Trait Implementations§

Source§

impl<T: Send, const N: usize> Send for ChunkStridedSliceRef<T, N>

Source§

impl<T: Sync, const N: usize> Sync for ChunkStridedSliceRef<T, N>

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for ChunkStridedSliceRef<T, N>

§

impl<T, const N: usize> RefUnwindSafe for ChunkStridedSliceRef<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Unpin for ChunkStridedSliceRef<T, N>

§

impl<T, const N: usize> UnsafeUnpin for ChunkStridedSliceRef<T, N>

§

impl<T, const N: usize> UnwindSafe for ChunkStridedSliceRef<T, N>
where T: RefUnwindSafe,

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.