org.eclipse.january.dataset

## Class PositionIterator

- java.lang.Object
- - org.eclipse.january.dataset.IndexIterator
  - - org.eclipse.january.dataset.PositionIterator

-     public class PositionIterator
      extends IndexIterator

  Class to provide iteration through a dataset

  Instantiate an iterator and use it in a while loop:

       Dataset ds = DatasetFactory.createLinearSpace(DoubleDataset.class, 0, 10, 0.25);
       PositionIterator iter = ds.getPositionIterator();
       int[] pos = iter.getPos()

       while (iter.hasNext()) {
           ds.set(1.2, pos);
       }

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.january.dataset.IndexIterator

      `index`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PositionIterator(int[] shape)` Constructor for an iterator over elements of a dataset that are within the shape
    `PositionIterator(int[] shape, int... axes)` Constructor for an iterator that misses out several axes
    `PositionIterator(int[] shape, int[] start, int[] stop, int[] step, int[] axes)` Constructor for an iterator that misses out several axes
    `PositionIterator(int[] shape, Slice[] slice, int[] axes)` Constructor for an iterator that misses out several axes
    `PositionIterator(int offset, int[] shape)` Constructor for an iterator over a single item broadcasted to given shape
    `PositionIterator(int offset, SliceND slice, int... axes)` Constructor for an iterator that misses out several axes
    `PositionIterator(SliceND slice, int... axes)` Constructor for an iterator that misses out several axes

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean[]` | `getOmit()`
    `int[]` | `getPos()`
    `int[]` | `getShape()`
    `int[]` | `getStop()`
    `boolean` | `hasNext()`
    `void` | `reset()` Reset iterator

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PositionIterator

          public PositionIterator(int[] shape)

      Constructor for an iterator over elements of a dataset that are within the shape
      Parameters:
        `shape` -

    - #### PositionIterator

          public PositionIterator(int offset,
                          int[] shape)

      Constructor for an iterator over a single item broadcasted to given shape
      Parameters:
        `offset` - offset to single item
        `shape` -

    - #### PositionIterator

          public PositionIterator(int[] shape,
                          int... axes)

      Constructor for an iterator that misses out several axes
      Parameters:
        `shape` -
        `axes` - missing axes, can be null for full dataset

    - #### PositionIterator

          public PositionIterator(int[] shape,
                          Slice[] slice,
                          int[] axes)

      Constructor for an iterator that misses out several axes
      Parameters:
        `shape` -
        `slice` -
        `axes` - missing axes

    - #### PositionIterator

          public PositionIterator(int[] shape,
                          int[] start,
                          int[] stop,
                          int[] step,
                          int[] axes)

      Constructor for an iterator that misses out several axes
      Parameters:
        `shape` -
        `start` -
        `stop` -
        `step` -
        `axes` - missing axes

    - #### PositionIterator

          public PositionIterator(SliceND slice,
                          int... axes)

      Constructor for an iterator that misses out several axes
      Parameters:
        `slice` -
        `axes` - missing axes

    - #### PositionIterator

          public PositionIterator(int offset,
                          SliceND slice,
                          int... axes)

      Constructor for an iterator that misses out several axes
      Parameters:
        `offset` - offset to start with
        `slice` -
        `axes` - missing axes

  - ### Method Detail

    - #### hasNext

          public boolean hasNext()

      Specified by:
        `hasNext` in class `IndexIterator`
      Returns:
        true if there is another iteration

    - #### getPos

          public int[] getPos()

      Specified by:
        `getPos` in class `IndexIterator`
      Returns:
        position indices (nb this is reference not a copy so avoid changing and can be null)

    - #### getOmit

          public boolean[] getOmit()

      Returns:
        omit array - array where true means miss out

    - #### reset

          public void reset()

      Description copied from class: `IndexIterator`
      Reset iterator
      Specified by:
        `reset` in class `IndexIterator`

    - #### getShape

          public int[] getShape()

      Overrides:
        `getShape` in class `IndexIterator`
      Returns:
        shape of iterator (can be null, if not known or applicable)

    - #### getStop

          public int[] getStop()

Copyright © 2014–2018 Eclipse Foundation. All rights reserved.