Class CoordinateIterator

java.lang.Object
org.olap4j.impl.CoordinateIterator
All Implemented Interfaces:
Iterator<int[]>

public class CoordinateIterator extends Object implements Iterator<int[]>
Iterator over the coordinates of a hyper-rectangle.

For example, new CoordinateIterator(new int[] {3, 2}) generates the pairs {0, 0}, {0, 1}, {1, 0}, {1, 1}, {2, 0}, {2, 1} .

Since:
Apr 7, 2009
Author:
jhyde
  • Constructor Details

    • CoordinateIterator

      public CoordinateIterator(int[] dimensions)
      Creates a big-endian coordinate iterator.
      Parameters:
      dimensions - Array containing the number of elements of each coordinate axis
    • CoordinateIterator

      public CoordinateIterator(int[] dimensions, boolean littleEndian)
      Creates a coordinate iterator.
      Parameters:
      dimensions - Array containing the number of elements of each
      littleEndian - Whether coordinate 0 is the least significant (and fastest changing) coordinate
  • Method Details

    • iterate

      public static Iterable<int[]> iterate(int[] dimensions)
      Creates an Iterable that yields a CoordinateIterator.

      Useful in a foreach loop, for example:

      int[] dimensions; for (int[] coords : CoordinateIterator.iterate(dimensions)) { foo(coords); }
      Parameters:
      dimensions - Array containing the number of elements of each coordinate axis
      Returns:
      Iterable
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<int[]>
    • next

      public int[] next()
      Specified by:
      next in interface Iterator<int[]>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<int[]>