Package org.olap4j.impl
Class CoordinateIterator
java.lang.Object
org.olap4j.impl.CoordinateIterator
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionCoordinateIterator
(int[] dimensions) Creates a big-endian coordinate iterator.CoordinateIterator
(int[] dimensions, boolean littleEndian) Creates a coordinate iterator. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
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 eachlittleEndian
- Whether coordinate 0 is the least significant (and fastest changing) coordinate
-
-
Method Details
-
iterate
Creates anIterable
that yields aCoordinateIterator
.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() -
next
public int[] next() -
remove
public void remove()
-