Returns a Collection of all the permutations of the specified Collection. Notes: This is an implementation of the Plain Changes algorithm for permutations generation, described in Knuth's "The Art of Computer Programming", Volume 4, Chapter 7, Section 7.2.1.2. If the i
(Collection<E> elements)
| 560 | */ |
| 561 | |
| 562 | @Beta |
| 563 | public static <E> Collection<List<E>> permutations(Collection<E> elements) { |
| 564 | return new PermutationCollection<E>(ImmutableList.copyOf(elements)); |
| 565 | } |
| 566 | |
| 567 | private static final class PermutationCollection<E> extends AbstractCollection<List<E>> { |
| 568 | final ImmutableList<E> inputList; |