Constructs an instance of the CartesianProduct class.
The input arrays for which the cartesian product will be computed.
Iterates over all combinations of the cartesian product and invokes the provided callback for each combination.
The function to be called for each combination, with the combination and its index as arguments.
Retrieves the combination (tuple) at a specific index in the Cartesian product.
The index is computed based on the total number of possible combinations (the product of the sizes of the input arrays).
If the provided index is outside the valid range (from 0 to total - 1), null is returned.
Mathematical Calculation: The total number of combinations is calculated as the product of the lengths of all input arrays:
total = size_1 * size_2 * ... * size_n
The index of the combination to retrieve, between 0 and total - 1.
The combination at the specified index, or null if the index is out of bounds.
Returns an iterator for iterating over the combinations in the cartesian product.
An iterator for the cartesian product.
Lazily computes the Cartesian product of multiple arrays or array-like objects.
The Cartesian product consists of all possible ordered combinations of the input arrays' elements whose type is infered automatically. This class implements the
Iterableinterface, allowing iteration withfor...ofand other iterable operations.Example