org.eclipse.january.dataset

## Class IndexIterator

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

- Direct Known Subclasses:
    BooleanIterator, BroadcastIteratorBase, ContiguousIterator, ContiguousIteratorWithPosition, IntegerIterator, IntegersIterator, PositionIterator, SingleInputBroadcastIterator, SingleItemIterator, SliceIterator, SliceNDIterator

      public abstract class IndexIterator
      extends Object

  Class to provide iteration through whole data array that backs a dataset

  Instantiate an iterator and use it in a while loop:

        DoubleDataset ds = DatasetFactory.createLinearSpace(DoubleDataset.class, 0, 10, 0.25);
        IndexIterator iter = ds.getIterator();
        double[] data = ds.getData();

        while (iter.hasNext()) {
            data[iter.index] = 1.2;
        }

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `index` Index in array

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IndexIterator()`

  - ### Method Summary

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

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

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

- - ### Field Detail

    - #### index

          public int index

      Index in array

  - ### Constructor Detail

    - #### IndexIterator

          public IndexIterator()

  - ### Method Detail

    - #### hasNext

          public abstract boolean hasNext()

      Returns:
        true if there is another iteration

    - #### getPos

          public abstract int[] getPos()

      Returns:
        position indices (nb this is reference not a copy so avoid changing and can be null)

    - #### reset

          public abstract void reset()

      Reset iterator

    - #### getShape

          public int[] getShape()

      Returns:
        shape of iterator (can be null, if not known or applicable)

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