Trait cell_map::iterators::slicers::Slicer[][src]

pub trait Slicer<'a, L, T> where
    L: Layer
{ type Output; type OutputMut; fn slice(&self, data: &'a Array2<T>) -> Option<Self::Output>;
fn slice_mut(&self, data: &'a mut Array2<T>) -> Option<Self::OutputMut>;
fn advance(&mut self);
fn index(&self) -> Option<Point2<usize>>;
fn reset(&mut self, layer: Option<L>); }
Expand description

Trait which allows a CellMapIter or CellMapIterMut struct to determine what shape the data in the iteration should be produced in. For example:

  • Cells produces data in each cell in (x, y) order, x increasing most rapidly.
  • Windows produces rectangular views in (x, y) order, x increasing most rapidly.
  • Line produces cells along the line connecting two positions in the parent frame.

Slicers are designed to be used in iterators, so after a .slice or .slice_mut the user shall call Slicer::advance() on the type.

Associated Types

The non-mutable output type for the data of this Slicer.

The mutable output type for the data of this Slicer.

Required methods

Perform the slice on the given data layer, or None if the slicer has reached the end of its data.

Perform a mutable slice on the given data layer, or None if the slicer has reached the end of its data.

Advance the Slicer to the next index.

Return the current index of the Slicer, or None if the slicer has reached the end of its data.

Resets the index of this Slicer so that it can be used on the next layer in the iteration. The layer input is used for slicers which need to monitor which layer they are on.

Implementors