Skip to main content

ArraySubsetTraits

Trait ArraySubsetTraits 

Source
pub trait ArraySubsetTraits: Indexer + Sealed {
Show 17 methods // Required methods fn start(&self) -> Cow<'_, [u64]>; fn shape(&self) -> Cow<'_, [u64]>; // Provided methods fn num_elements(&self) -> u64 { ... } fn num_elements_usize(&self) -> usize { ... } fn end_exc(&self) -> ArrayIndices { ... } fn end_inc(&self) -> Option<ArrayIndices> { ... } fn to_ranges(&self) -> Vec<Range<u64>> { ... } fn contains(&self, indices: &[u64]) -> bool { ... } fn inbounds_shape(&self, array_shape: &[u64]) -> bool { ... } fn inbounds(&self, other: &dyn ArraySubsetTraits) -> bool { ... } fn overlap( &self, other: &dyn ArraySubsetTraits, ) -> Result<ArraySubset, ArraySubsetError> { ... } fn relative_to( &self, offset: &[u64], ) -> Result<ArraySubset, ArraySubsetError> { ... } fn to_array_subset(&self) -> ArraySubset { ... } fn indices(&self) -> Indices { ... } fn linearised_indices( &self, array_shape: &[u64], ) -> Result<LinearisedIndices, IndexerError> { ... } fn contiguous_indices( &self, array_shape: &[u64], ) -> Result<ContiguousIndices, IndexerError> { ... } fn contiguous_linearised_indices( &self, array_shape: &[u64], ) -> Result<ContiguousLinearisedIndices, IndexerError> { ... }
}
Expand description

Trait for types that represent an array region (start and shape).

This trait enables ergonomic APIs that accept various region representations, including ArraySubset, arrays of ranges like [0..5, 0..10], and slices of ranges.

Required Methods§

Source

fn start(&self) -> Cow<'_, [u64]>

Returns the start indices of the subset.

Source

fn shape(&self) -> Cow<'_, [u64]>

Returns the shape (size along each dimension) of the subset.

Provided Methods§

Source

fn num_elements(&self) -> u64

Returns the total number of elements.

Source

fn num_elements_usize(&self) -> usize

Returns the number of elements as usize.

§Panics

Panics if num_elements() is greater than usize::MAX.

Source

fn end_exc(&self) -> ArrayIndices

Returns exclusive end indices.

Source

fn end_inc(&self) -> Option<ArrayIndices>

Returns inclusive end indices, or None if empty.

Source

fn to_ranges(&self) -> Vec<Range<u64>>

Converts to ranges.

Source

fn contains(&self, indices: &[u64]) -> bool

Returns true if the region contains the given indices.

Source

fn inbounds_shape(&self, array_shape: &[u64]) -> bool

Returns true if the region is within the bounds of an array with the given shape.

Source

fn inbounds(&self, other: &dyn ArraySubsetTraits) -> bool

Returns true if the region is within another region.

Source

fn overlap( &self, other: &dyn ArraySubsetTraits, ) -> Result<ArraySubset, ArraySubsetError>

Return the overlapping subset between this region and other.

§Errors

Returns ArraySubsetError if the dimensionality of other does not match.

Source

fn relative_to(&self, offset: &[u64]) -> Result<ArraySubset, ArraySubsetError>

Return the region relative to offset.

Creates an array subset starting at self.start() - offset.

§Errors

Returns ArraySubset if the length of offset does not match the dimensionality, or if offset is greater than start in any dimension.

Source

fn to_array_subset(&self) -> ArraySubset

Converts to an owned ArraySubset.

Source

fn indices(&self) -> Indices

Returns an iterator over the indices of elements within the subset.

Source

fn linearised_indices( &self, array_shape: &[u64], ) -> Result<LinearisedIndices, IndexerError>

Returns an iterator over the linearised indices of elements within the subset.

§Errors

Returns IndexerError if the array_shape does not encapsulate this array subset.

Source

fn contiguous_indices( &self, array_shape: &[u64], ) -> Result<ContiguousIndices, IndexerError>

Returns an iterator over the indices of contiguous elements within the subset.

§Errors

Returns IndexerError if the array_shape does not encapsulate this array subset.

Source

fn contiguous_linearised_indices( &self, array_shape: &[u64], ) -> Result<ContiguousLinearisedIndices, IndexerError>

Returns an iterator over the linearised indices of contiguous elements within the subset.

§Errors

Returns IndexerError if the array_shape does not encapsulate this array subset.

Trait Implementations§

Source§

impl PartialEq<&dyn ArraySubsetTraits> for ArraySubset

Source§

fn eq(&self, other: &&dyn ArraySubsetTraits) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<ArraySubset> for &dyn ArraySubsetTraits

Source§

fn eq(&self, other: &ArraySubset) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementations on Foreign Types§

Source§

impl ArraySubsetTraits for &[Range<u64>]

Source§

fn start(&self) -> Cow<'_, [u64]>

Source§

fn shape(&self) -> Cow<'_, [u64]>

Source§

impl ArraySubsetTraits for Vec<Range<u64>>

Source§

fn start(&self) -> Cow<'_, [u64]>

Source§

fn shape(&self) -> Cow<'_, [u64]>

Source§

impl<const N: usize> ArraySubsetTraits for [Range<u64>; N]

Source§

fn start(&self) -> Cow<'_, [u64]>

Source§

fn shape(&self) -> Cow<'_, [u64]>

Implementors§