Package edu.cmu.tetrad.util
Class CombinationGenerator
java.lang.Object
edu.cmu.tetrad.util.CombinationGenerator
Generates (nonrecursively) all of the combinations of objects, where the number of objects in each dimension is
specified. The sequence of choices is obtained by repeatedly calling the next() method. When the sequence is
finished, null is returned.
A valid combination for the sequence of combinations for a choose b generated by this class is an array x[] of b integers i, 0 <= i < a, such that x[j] < x[j + 1] for each j from 0 to b - 1.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Constructor Summary
ConstructorsConstructorDescriptionCombinationGenerator
(int[] dims) Constructs a new combination of objects, choosing one object from each dimension. -
Method Summary
-
Constructor Details
-
CombinationGenerator
public CombinationGenerator(int[] dims) Constructs a new combination of objects, choosing one object from each dimension.- Parameters:
dims
- the number of objects in each dimension. Each member must be >= 0.- Throws:
NullPointerException
- if dims is null.
-
-
Method Details
-
testPrint
public static void testPrint(int[] dims) This static method will print the series of combinations for a choose b to System.out.- Parameters:
dims
- An int array consisting of the number of dimensions for each variable, in order.
-
next
public int[] next()next.
- Returns:
- the next combination in the series, or null if the series is finished.
-