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.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean[] | |
| private final int[] | keys
Permutation is done on theses keys to handle equal objects. |
| private List | nextPermutation
Next permutation to return. |
| private final Map | objectMap
Mapping between keys and objects. |
| Access | Constructor and Description |
|---|---|
| public | PermutationIterator(final Collection<? extends E>
the collection to generate permutations for coll)Standard constructor for this class. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if there are more permutations, otherwise falseImplements java. |
| public List | Returns: a list of the permutator's elements representing a permutationImplements java. |
| public void | remove()
Overrides default java. |
| direction | back to summary |
|---|---|
| private final boolean[] direction Direction table used in the algorithm:
| |
| keys | back to summary |
|---|---|
| private final int[] keys Permutation is done on theses keys to handle equal objects. | |
| nextPermutation | back to summary |
|---|---|
| private List<E> nextPermutation Next permutation to return. When a permutation is requested this instance is provided and the next one is computed. | |
| objectMap | back to summary |
|---|---|
| private final Map<Integer, E> objectMap Mapping between keys and objects. | |
| PermutationIterator | back to summary |
|---|---|
| public PermutationIterator(final Collection<? extends E> coll) Standard constructor for this class.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Indicates if there are more permutation available.
| |
| next | back to summary |
|---|---|
| public List Implements java. Returns the next permutation of the input collection.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |