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§
Provided Methods§
Sourcefn num_elements(&self) -> u64
fn num_elements(&self) -> u64
Returns the total number of elements.
Sourcefn num_elements_usize(&self) -> usize
fn num_elements_usize(&self) -> usize
Returns the number of elements as usize.
§Panics
Panics if num_elements() is greater than usize::MAX.
Sourcefn end_exc(&self) -> ArrayIndices
fn end_exc(&self) -> ArrayIndices
Returns exclusive end indices.
Sourcefn end_inc(&self) -> Option<ArrayIndices>
fn end_inc(&self) -> Option<ArrayIndices>
Returns inclusive end indices, or None if empty.
Sourcefn contains(&self, indices: &[u64]) -> bool
fn contains(&self, indices: &[u64]) -> bool
Returns true if the region contains the given indices.
Sourcefn inbounds_shape(&self, array_shape: &[u64]) -> bool
fn inbounds_shape(&self, array_shape: &[u64]) -> bool
Returns true if the region is within the bounds of an array with the given shape.
Sourcefn inbounds(&self, other: &dyn ArraySubsetTraits) -> bool
fn inbounds(&self, other: &dyn ArraySubsetTraits) -> bool
Returns true if the region is within another region.
Sourcefn overlap(
&self,
other: &dyn ArraySubsetTraits,
) -> Result<ArraySubset, ArraySubsetError>
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.
Sourcefn relative_to(&self, offset: &[u64]) -> Result<ArraySubset, ArraySubsetError>
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.
Sourcefn to_array_subset(&self) -> ArraySubset
fn to_array_subset(&self) -> ArraySubset
Converts to an owned ArraySubset.
Sourcefn indices(&self) -> Indices
fn indices(&self) -> Indices
Returns an iterator over the indices of elements within the subset.
Sourcefn linearised_indices(
&self,
array_shape: &[u64],
) -> Result<LinearisedIndices, IndexerError>
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.
Sourcefn contiguous_indices(
&self,
array_shape: &[u64],
) -> Result<ContiguousIndices, IndexerError>
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.
Sourcefn contiguous_linearised_indices(
&self,
array_shape: &[u64],
) -> Result<ContiguousLinearisedIndices, IndexerError>
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.