Struct zarrs::array_subset::iterators::ContiguousLinearisedIndices
source · pub struct ContiguousLinearisedIndices { /* private fields */ }
Expand description
Iterates over contiguous linearised element indices in an array subset.
The iterator item is a tuple: (linearised index, # contiguous elements).
Iterates over the last dimension fastest (i.e. C-contiguous order). For example, consider a 4x3 array with linearised element indices
0 1 2
3 4 5
6 7 8
9 10 11
An iterator with an array subset covering the entire array will produce
[(0, 9)]
An iterator with an array subset corresponding to the lower right 2x2 region will produce
[(7, 2), (10, 2)]
Implementations§
source§impl ContiguousLinearisedIndices
impl ContiguousLinearisedIndices
sourcepub fn new(
subset: &ArraySubset,
array_shape: Vec<u64>
) -> Result<Self, IncompatibleArraySubsetAndShapeError>
pub fn new( subset: &ArraySubset, array_shape: Vec<u64> ) -> Result<Self, IncompatibleArraySubsetAndShapeError>
Return a new contiguous linearised indices iterator.
§Errors
Returns IncompatibleArraySubsetAndShapeError
if array_shape
does not encapsulate subset
.
sourcepub unsafe fn new_unchecked(subset: &ArraySubset, array_shape: Vec<u64>) -> Self
pub unsafe fn new_unchecked(subset: &ArraySubset, array_shape: Vec<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) -> ContiguousLinearisedIndicesIterator<'_> ⓘ
pub fn iter(&self) -> ContiguousLinearisedIndicesIterator<'_> ⓘ
Create a new serial iterator.