Class AbstractCursor<T>

Type Parameters:
T -
All Implemented Interfaces:
Iterator<T>, Cursor<T>, EuclideanSpace, Iterator, Localizable, RealCursor<T>, RealLocalizable, Sampler<T>, Typed<T>
Direct Known Subclasses:
AbstractLongListImg.LongListCursor, CellCursor

public abstract class AbstractCursor<T> extends AbstractEuclideanSpace implements Cursor<T>
Abstract implementation of Cursor. Java's Iterator interface is implemented by mapping to abstract Iterator.fwd() and Sampler.get().

For localization, default implementations are available that all build on the abstract long variant. For particular cursors, this may be implemented more efficiently saving at least one loop over n.

  • Field Details

    • tmp

      private final long[] tmp
      used internally to forward all localize() versions to the (abstract) long[] version.
  • Constructor Details

    • AbstractCursor

      public AbstractCursor(int n)
      Parameters:
      n - number of dimensions in the Img.
  • Method Details

    • localize

      public void localize(float[] pos)
      Description copied from interface: RealLocalizable
      Write the current position into the passed array.
      Specified by:
      localize in interface RealLocalizable
      Parameters:
      pos - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • localize

      public void localize(double[] pos)
      Description copied from interface: RealLocalizable
      Write the current position into the passed array.
      Specified by:
      localize in interface RealLocalizable
      Parameters:
      pos - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • localize

      public void localize(int[] pos)
      Description copied from interface: Localizable
      Write the current position into the passed array.
      Specified by:
      localize in interface Localizable
      Parameters:
      pos - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • getFloatPosition

      public float getFloatPosition(int d)
      Description copied from interface: RealLocalizable
      Return the current position in a given dimension.
      Specified by:
      getFloatPosition in interface Localizable
      Specified by:
      getFloatPosition in interface RealLocalizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • getDoublePosition

      public double getDoublePosition(int d)
      Description copied from interface: RealLocalizable
      Return the current position in a given dimension.
      Specified by:
      getDoublePosition in interface Localizable
      Specified by:
      getDoublePosition in interface RealLocalizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • getIntPosition

      public int getIntPosition(int d)
      Description copied from interface: Localizable
      Return the current position in a given dimension.
      Specified by:
      getIntPosition in interface Localizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public abstract AbstractCursor<T> copy()
      Specified by:
      copy in interface Cursor<T>
      Specified by:
      copy in interface RealCursor<T>
      Specified by:
      copy in interface Sampler<T>
      Returns:
      - A new Sampler in the same state accessing the same values. It does NOT copy T, just the state of the Sampler. Otherwise use T.copy() if available. Sampler.copy().get() == Sampler.get(), i.e. both hold the same value, not necessarily the same instance (this is the case for an ArrayCursor for example)