Class PermutationIterator<E>
java.lang.Object
org.apache.commons.collections4.iterators.PermutationIterator<E>
- Type Parameters:
E- the type of the objects being permuted
This iterator creates permutations of an input collection, using the
Steinhaus-Johnson-Trotter algorithm (also called plain changes).
The iterator will return exactly n! permutations of the input collection.
The remove() operation is not supported, and will throw an
UnsupportedOperationException.
NOTE: in case an empty collection is provided, the iterator will return exactly one empty list as result, as 0! = 1.
- Since:
- 4.0
-
Constructor Summary
ConstructorsConstructorDescriptionPermutationIterator(Collection<? extends E> collection) Standard constructor for this class. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
PermutationIterator
Standard constructor for this class.- Parameters:
collection- the collection to generate permutations for- Throws:
NullPointerException- if coll is null
-
-
Method Details
-
hasNext
-
next
-
remove
-