Struct zarrs::array_subset::iterators::ContiguousIndices
source · pub struct ContiguousIndices { /* private fields */ }
Expand description
Iterates over contiguous element indices in an array subset.
The iterator item is a tuple: (indices, # contiguous elements).
Iterates over the last dimension fastest (i.e. C-contiguous order). For example, consider a 4x3 array with element indices
(0, 0) (0, 1) (0, 2)
(1, 0) (1, 1) (1, 2)
(2, 0) (2, 1) (2, 2)
(3, 0) (3, 1) (3, 2)
An iterator with an array subset covering the entire array will produce
[((0, 0), 9)]
An iterator with an array subset corresponding to the lower right 2x2 region will produce
[((2, 1), 2), ((3, 1), 2)]
Implementations§
source§impl ContiguousIndices
impl ContiguousIndices
sourcepub fn new(
subset: &ArraySubset,
array_shape: &[u64]
) -> Result<Self, IncompatibleArraySubsetAndShapeError>
pub fn new( subset: &ArraySubset, array_shape: &[u64] ) -> Result<Self, IncompatibleArraySubsetAndShapeError>
Create a new contiguous indices iterator.
§Errors
Returns IncompatibleArraySubsetAndShapeError
if array_shape
does not encapsulate subset
.
sourcepub unsafe fn new_unchecked(subset: &ArraySubset, array_shape: &[u64]) -> Self
pub unsafe fn new_unchecked(subset: &ArraySubset, array_shape: &[u64]) -> Self
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of starting indices (i.e. the length of the iterator).
sourcepub fn contiguous_elements(&self) -> u64
pub fn contiguous_elements(&self) -> u64
Return the number of contiguous elements (fixed on each iteration).
sourcepub fn contiguous_elements_usize(&self) -> usize
pub fn contiguous_elements_usize(&self) -> usize
Return the number of contiguous elements (fixed on each iteration).
§Panics
Panics if the number of contiguous elements exceeds usize::MAX
.
sourcepub fn iter(&self) -> ContiguousIndicesIterator<'_> ⓘ
pub fn iter(&self) -> ContiguousIndicesIterator<'_> ⓘ
Create a new serial iterator.