E
- the type of the objects being permutedpublic class PermutationIterator<E> extends Object implements Iterator<List<E>>
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 and Description |
---|
PermutationIterator(Collection<? extends E> coll)
Standard constructor for this class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Indicates if there are more permutation available.
|
List<E> |
next()
Returns the next permutation of the input collection.
|
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public PermutationIterator(Collection<? extends E> coll)
coll
- the collection to generate permutations forNullPointerException
- if coll is nullpublic boolean hasNext()
public List<E> next()
next
in interface Iterator<List<E>>
NoSuchElementException
- if there are no more permutationsCopyright © 2001–2019 The Apache Software Foundation. All rights reserved.