|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections4.iterators.PermutationIterator<E>
E
- the type of the objects being permutedpublic class PermutationIterator<E>
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.
Constructor Summary | |
---|---|
PermutationIterator(Collection<E> coll)
Standard constructor for this class. |
Method Summary | |
---|---|
boolean |
hasNext()
Indicates if there are more permutation available. |
List<E> |
next()
Returns the next permutation of the input collection. |
void |
remove()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PermutationIterator(Collection<E> coll)
coll
- the collection to generate permutations for
NullPointerException
- if coll is nullMethod Detail |
---|
public boolean hasNext()
hasNext
in interface Iterator<List<E>>
public List<E> next()
next
in interface Iterator<List<E>>
NoSuchElementException
- if there are no more permutationspublic void remove()
remove
in interface Iterator<List<E>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |