de.torstennahm.integrate.sparse.index
Class FlatIndexGenerator

java.lang.Object
  extended by de.torstennahm.integrate.sparse.index.FlatIndexGenerator
All Implemented Interfaces:
de.torstennahm.series.Series<Index>

public class FlatIndexGenerator
extends java.lang.Object
implements de.torstennahm.series.Series<Index>

Iterates over all indices with a given dimension, or with infinite dimension. All indices are returned exactly once. The exact order in which indices are provided is not specified. However, indices are returned so that for each index provided, all smaller indices (with regard to the canonical partial ordering of indices) have been returned before it. In addition, for finite dimension, it is also guaranteed that the length of the returned indices (that is, the sum of their components) increases monotonously. This is not possible for infinite dimension.

This class is NOT thread-safe.

Author:
Torsten Nahm

Constructor Summary
FlatIndexGenerator(int dimension)
          Creates the index iterator.
FlatIndexGenerator(int dimension, int minLength, int maxLength)
          Creates the index generator with specified minimum and maximum length.
 
Method Summary
 boolean hasNext()
           
 Index next()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlatIndexGenerator

public FlatIndexGenerator(int dimension)
Creates the index iterator.

Parameters:
dimension - dimension of the indices

FlatIndexGenerator

public FlatIndexGenerator(int dimension,
                          int minLength,
                          int maxLength)
Creates the index generator with specified minimum and maximum length.

Parameters:
dimension -
minLength - start length of indices
maxLength - maximum length of indices, -1 for infinite
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface de.torstennahm.series.Series<Index>

next

public Index next()
Specified by:
next in interface de.torstennahm.series.Series<Index>