Trait Slicer

Source
pub trait Slicer<'a, L, T>
where L: Layer,
{ type Output; type OutputMut; // Required methods 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.

Required Associated Types§

Source

type Output

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

Source

type OutputMut

The mutable output type for the data of this Slicer.

Required Methods§

Source

fn slice(&self, data: &'a Array2<T>) -> Option<Self::Output>

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

Source

fn slice_mut(&self, data: &'a mut Array2<T>) -> Option<Self::OutputMut>

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

Source

fn advance(&mut self)

Advance the Slicer to the next index.

Source

fn index(&self) -> Option<Point2<usize>>

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

Source

fn reset(&mut self, layer: Option<L>)

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§

Source§

impl<'a, L, T> Slicer<'a, L, T> for Cells
where L: Layer, T: 'a,

Source§

impl<'a, L, T> Slicer<'a, L, T> for Line
where L: Layer, T: 'a,

Source§

impl<'a, L, T> Slicer<'a, L, T> for Windows
where L: Layer, T: 'a,

Source§

impl<'a, L, T, S> Slicer<'a, L, T> for Indexed<'a, L, T, S>
where L: Layer, S: Slicer<'a, L, T>,

Source§

type Output = ((L, Point<usize, U2>), <S as Slicer<'a, L, T>>::Output)

Source§

type OutputMut = ((L, Point<usize, U2>), <S as Slicer<'a, L, T>>::OutputMut)

Source§

impl<'a, L, T, S> Slicer<'a, L, T> for Positioned<'a, L, T, S>
where L: Layer, S: Slicer<'a, L, T>,

Source§

type Output = ((L, Point<f64, U2>), <S as Slicer<'a, L, T>>::Output)

Source§

type OutputMut = ((L, Point<f64, U2>), <S as Slicer<'a, L, T>>::OutputMut)