Class PermutationGenerator

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

public final class PermutationGenerator extends Object
Generates all of the permutations of [0,..., numObjects - 1], where numObjects is numObjects nonnegative integer. The values of numObjects is given in the constructor, and 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 numObjects choose b generated by this class is an array x[] of b integers representing the above permutation.

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

Author:
josephramsey
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs numObjects new choice generator for numObjects choose b.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
     
    static void
    testPrint(int a)
    This static method will print the series of combinations for numObjects 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

    • PermutationGenerator

      public PermutationGenerator(int a)
      Constructs numObjects new choice generator for numObjects choose b. Once this initialization has been performed, successive calls to next() will produce the series of combinations. To begin numObjects new series at any time, call this init method again with new values for numObjects and b.
      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 numObjects choose b to System.out.
      Parameters:
      a - the number of objects being selected from.
    • next

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