Package org.xcsp.common.enumerations
Class EnumerationOfCombinations
- java.lang.Object
-
- org.xcsp.common.enumerations.EnumerationAbstract
-
- org.xcsp.common.enumerations.EnumerationCartesian
-
- org.xcsp.common.enumerations.EnumerationOfCombinations
-
- All Implemented Interfaces:
Iterator<int[]>
public class EnumerationOfCombinations extends EnumerationCartesian
This class allows us to iterate over all combinations of a given length from a given set of values. Execute the main method for an illustration.
-
-
Field Summary
-
Fields inherited from class org.xcsp.common.enumerations.EnumerationCartesian
values
-
Fields inherited from class org.xcsp.common.enumerations.EnumerationAbstract
currTupleOfIdxs, indexesMatchValues, nextTuple
-
-
Constructor Summary
Constructors Constructor Description EnumerationOfCombinations(int[] nValues)
Builds an object that can be used for enumerating combinations, using the specified numbers of values.EnumerationOfCombinations(int nValues, int tupleLength)
Builds an object that can be used for enumerating combinations, using the specified number of values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
computeFirstTuple()
Computes the first tuple (called at reset time).boolean
hasNext()
static void
main(String[] args)
-
Methods inherited from class org.xcsp.common.enumerations.EnumerationCartesian
tuplesWithDiffValuesSummingTo, valAt
-
Methods inherited from class org.xcsp.common.enumerations.EnumerationAbstract
displayAllTuples, execute, next, reset, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Constructor Detail
-
EnumerationOfCombinations
public EnumerationOfCombinations(int[] nValues)
Builds an object that can be used for enumerating combinations, using the specified numbers of values.- Parameters:
nValues
- the number of possible different values at each position of the tuples. These numbers must be in an increasing order (and are usually all equal)
-
EnumerationOfCombinations
public EnumerationOfCombinations(int nValues, int tupleLength)
Builds an object that can be used for enumerating combinations, using the specified number of values. Each tuple (combination) has the specified length.- Parameters:
nValues
- the number of values used to form combinationstupleLength
- the length of each combination
-
-
Method Detail
-
computeFirstTuple
protected void computeFirstTuple()
Description copied from class:EnumerationAbstract
Computes the first tuple (called at reset time).- Overrides:
computeFirstTuple
in classEnumerationCartesian
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<int[]>
- Overrides:
hasNext
in classEnumerationCartesian
-
main
public static void main(String[] args)
-
-