Class CombinationIterator

java.lang.Object
edu.cmu.tetrad.util.CombinationIterator
All Implemented Interfaces:
Iterator

public class CombinationIterator extends Object implements Iterator
Iterates through all the posible combinations for a set of variables (each with a different number of possible values). For example, if the number of values for each variable is two, this would iterate through a truth table. Not to be confused with a combinatorial (taking n values from m possible values).
Author:
Juan Casares
  • Constructor Details

    • CombinationIterator

      public CombinationIterator(int[] maxValues)
      Creates a combination set for a set of variables with the given number of maxValues
      Parameters:
      maxValues - An int array consisting of the maximum values of each variable, in order.
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator
      Returns:
      true iff there is still a combination that has not been returned by the next() method.
    • next

      public int[] next()
      Specified by:
      next in interface Iterator
      Returns:
      an int[] array with the next combination.
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator