From 8f121670d492a77f3d782823500bc6bd2c377ef5 Mon Sep 17 00:00:00 2001
From: Gary Gregory
{@code * List- * + *iterable1 = Arrays.asList('A', 'B', 'C'); * List iterable2 = Arrays.asList('1', '2', '3'); @@ -41,9 +41,9 @@ * System.out.println(tuple.get(0) + ", " + tuple.get(1)); * } * }
* The output will be: - * + *
** A, 1 * A, 2 @@ -58,10 +58,12 @@ ** The {@code remove()} operation is not supported, and will throw an * {@code UnsupportedOperationException}. + *
** If any of the input iterables is empty, the Cartesian product will be empty. * If any of the input iterables is infinite, the Cartesian product will be * infinite. + *
* * @paramthe type of the objects being permuted * @since 4.5.0 @@ -127,7 +129,6 @@ public List next() { if (!hasNext()) { throw new NoSuchElementException(); } - if (previousTuple == null) { previousTuple = new ArrayList<>(iterables.size()); for (final Iterator extends E> iterator : iterators) { @@ -135,7 +136,6 @@ public List next() { } return new ArrayList<>(previousTuple); } - for (int i = iterators.size() - 1; i >= 0; i--) { Iterator extends E> iterator = iterators.get(i); if (iterator.hasNext()) {