pub struct ArrayBuf<Tag> { /* private fields */ }Expand description
Generic dense N-dimensional buffer parameterized by an element-type tag.
NumericArray = ArrayBuf<NumericArrayEnum> and
PackedArray = ArrayBuf<PackedArrayEnum>. Each provides specialized
constructors (from_slice<T: …Element>) and a typed slice view; shape,
byte access, and element count are shared via this struct.
Implementations§
Source§impl<Tag: Copy + PartialEq> ArrayBuf<Tag>
impl<Tag: Copy + PartialEq> ArrayBuf<Tag>
Sourcepub fn new(data_type: Tag, dimensions: Vec<usize>, bytes: ByteArray) -> Self
pub fn new(data_type: Tag, dimensions: Vec<usize>, bytes: ByteArray) -> Self
Construct from raw parts. Caller is responsible for ensuring
bytes.len() == prod(dimensions) * element_size.
Sourcepub fn dimensions(&self) -> &[usize]
pub fn dimensions(&self) -> &[usize]
Multi-dimensional shape.
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Total element count = product of dimensions.
Sourcepub fn byte_count(&self) -> usize
pub fn byte_count(&self) -> usize
Total byte length of the buffer.
Sourcepub fn from_slice<T: ArrayElement<Tag>>(
dimensions: Vec<usize>,
slice: &[T],
) -> Self
pub fn from_slice<T: ArrayElement<Tag>>( dimensions: Vec<usize>, slice: &[T], ) -> Self
Construct from a typed slice. Dimensions must satisfy
prod(dimensions) == slice.len().
Sourcepub fn try_as_slice<T: ArrayElement<Tag>>(&self) -> Option<&[T]>
pub fn try_as_slice<T: ArrayElement<Tag>>(&self) -> Option<&[T]>
Try to view the buffer as a slice of T. Returns None if T’s tag
doesn’t match this array’s data_type.
Trait Implementations§
impl<Tag: Eq> Eq for ArrayBuf<Tag>
Source§impl From<ArrayBuf<NumericArrayEnum>> for Expr
impl From<ArrayBuf<NumericArrayEnum>> for Expr
Source§fn from(a: NumericArray) -> Expr
fn from(a: NumericArray) -> Expr
Converts to this type from the input type.
Source§impl From<ArrayBuf<PackedArrayEnum>> for Expr
impl From<ArrayBuf<PackedArrayEnum>> for Expr
Source§fn from(a: PackedArray) -> Expr
fn from(a: PackedArray) -> Expr
Converts to this type from the input type.
Source§impl<Tag: Into<NumericArrayEnum> + Copy + PartialEq> NumericArrayRead for ArrayBuf<Tag>
impl<Tag: Into<NumericArrayEnum> + Copy + PartialEq> NumericArrayRead for ArrayBuf<Tag>
Source§fn data_type(&self) -> NumericArrayEnum
fn data_type(&self) -> NumericArrayEnum
The element-type tag.
Source§fn dimensions(&self) -> &[usize]
fn dimensions(&self) -> &[usize]
The multi-dimensional shape (row-major).
Source§fn element_count(&self) -> usize
fn element_count(&self) -> usize
Total element count = product of dimensions.
Source§fn byte_count(&self) -> usize
fn byte_count(&self) -> usize
Total byte length of the buffer.
Source§fn element_size(&self) -> usize
fn element_size(&self) -> usize
Bytes per element.
Source§fn try_as_slice<T: ArrayElement<NumericArrayEnum>>(&self) -> Option<&[T]>
fn try_as_slice<T: ArrayElement<NumericArrayEnum>>(&self) -> Option<&[T]>
View the buffer as
&[T] if T’s element type matches; else None.Source§impl<Tag: Ord> Ord for ArrayBuf<Tag>
impl<Tag: Ord> Ord for ArrayBuf<Tag>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<Tag: PartialEq> PartialEq for ArrayBuf<Tag>
impl<Tag: PartialEq> PartialEq for ArrayBuf<Tag>
Source§impl<Tag: PartialOrd> PartialOrd for ArrayBuf<Tag>
impl<Tag: PartialOrd> PartialOrd for ArrayBuf<Tag>
impl<Tag: PartialEq> StructuralPartialEq for ArrayBuf<Tag>
Auto Trait Implementations§
impl<Tag> Freeze for ArrayBuf<Tag>where
Tag: Freeze,
impl<Tag> RefUnwindSafe for ArrayBuf<Tag>where
Tag: RefUnwindSafe,
impl<Tag> Send for ArrayBuf<Tag>where
Tag: Send,
impl<Tag> Sync for ArrayBuf<Tag>where
Tag: Sync,
impl<Tag> Unpin for ArrayBuf<Tag>where
Tag: Unpin,
impl<Tag> UnsafeUnpin for ArrayBuf<Tag>where
Tag: UnsafeUnpin,
impl<Tag> UnwindSafe for ArrayBuf<Tag>where
Tag: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more