E - the type of the objects being permuted
public class PermutationIterator<E> extends Objectimplements 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
Standard constructor for this class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Indicates if there are more permutation available.
|
List |
next()
Returns the next permutation of the input collection.
|
void |
remove()
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic PermutationIterator(Collection<? extends E> coll)
coll - the collection to generate permutations for
NullPointerException - if coll is null
public boolean hasNext()
public List<E> next()
next in interface
Iterator<List<E>>
NoSuchElementException - if there are no more permutations
public void remove()