public final class PermutationIterator<T>
extends java.lang.Object
implements java.util.Iterator<java.util.List<T>>
Modifier and Type | Field and Description |
---|---|
private boolean |
anyLeft |
private boolean |
first |
private boolean |
foundNext |
private int |
nextSwap |
private java.util.List<T> |
permList |
private PermGen |
pg |
Constructor and Description |
---|
PermutationIterator(java.util.List<T> list)
Set up a permutation generator for the passed list.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
hasNext should not change things if called repeatedly,
so when it's called we'll lazily evaluate the next
permutation, and then keep returning true until next()
is called.
|
java.util.List<T> |
next() |
void |
remove() |
private void |
swap(int lower)
Swap elements lower and lower + 1 of permList
|
private final java.util.List<T> permList
private final PermGen pg
private boolean foundNext
private boolean anyLeft
private boolean first
private int nextSwap
public PermutationIterator(java.util.List<T> list)
public boolean hasNext()
hasNext
in interface java.util.Iterator<java.util.List<T>>
public java.util.List<T> next()
next
in interface java.util.Iterator<java.util.List<T>>
public void remove()
remove
in interface java.util.Iterator<java.util.List<T>>
private void swap(int lower)