Package net.sf.colossus.util
Class PermutationIterator<T>
java.lang.Object
net.sf.colossus.util.PermutationIterator<T>
An iterator that returns permutations of the originally passed list.
The first permutation is the unmodified list.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPermutationIterator
(List<T> list) Set up a permutation generator for the passed list. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.next()
void
remove()
private void
swap
(int lower) Swap elements lower and lower + 1 of permListMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
permList
-
pg
-
foundNext
private boolean foundNext -
anyLeft
private boolean anyLeft -
first
private boolean first -
nextSwap
private int nextSwap
-
-
Constructor Details
-
PermutationIterator
Set up a permutation generator for the passed list.
-
-
Method Details
-
hasNext
public 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. -
next
-
remove
public void remove() -
swap
private void swap(int lower) Swap elements lower and lower + 1 of permList
-