Class SelectionGenerator

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

public final class SelectionGenerator extends Object
Generates (nonrecursively) all of the selections from a items, where a is a nonnegative integer. The values of a is given in the constructor, and the sequence of seletions is obtained by repeatedly calling the next() method. When the sequence is finished, null is returned.> 0

A valid combination for the sequence of combinations for a generated by this class is an array x[] of a integers i, 0 <= i < a.

To see what this class does, try calling SelectionGenerator.testPrint(5, 3), for instance.

Author:
josephramsey
  • Constructor Details

    • SelectionGenerator

      public SelectionGenerator(int a)
      Constructs a new selection generator for a items. Once this initialization has been performed, successive calls to next() will produce the series of selections.
      Parameters:
      a - the number of objects being selected from.
  • Method Details

    • testPrint

      public static void testPrint(int a)
      This static method will print the series of combinations for a choose b to System.out.
      Parameters:
      a - the number of objects being selected from.
    • next

      public int[] next()
      Returns:
      the next selection in the series, or null if the series is finished.
    • getA

      public int getA()
      Returns:
      Ibid.