Class CombinationGenerator

java.lang.Object
edu.cmu.tetrad.util.CombinationGenerator

public final class CombinationGenerator extends Object
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.

Author:
josephramsey
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new combination of objects, choosing one object from each dimension.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
     
    static void
    testPrint(int[] dims)
    This static method will print the series of combinations for a choose b to System.out.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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()
      Returns:
      the next combination in the series, or null if the series is finished.