Class CartesianProductIterator<T>
java.lang.Object
com.amalgamasimulation.core.combinatorics.CartesianProductIterator<T>
- Type Parameters:
T
- the type of elements in the input lists and the combinations produced by this iterator
An iterator over all possible combinations (Cartesian product) of the
elements from the provided multiple lists of elements of type
T
, one
element from each list. This class provides an iterative approach to
generating and traversing each combination, without generating all
combinations in memory upfront.
For example, given two lists ["1", "2"]
and ["A", "B"]
, the
Cartesian product would be
[["1", "A"], ["1", "B"], ["2", "A"], ["2", "B"]]
.
The elements are generated in the lexicographical order
- Author:
- Andrey Malykhanov
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCartesianProductIterator
(List<? extends List<? extends T>> elementLists) Creates a new instance of An iterator over all possible combinations (Cartesian product) of the elements from the provided multiple lists of elements, one element from each list. -
Method Summary
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 Details
-
CartesianProductIterator
Creates a new instance of An iterator over all possible combinations (Cartesian product) of the elements from the provided multiple lists of elements, one element from each list.- Parameters:
elementLists
- list of lists of elements, from which the combinations are generated- See Also:
-
-
Method Details