Package net.sf.colossus.util
Class PermutationIterator<T>
- java.lang.Object
-
- net.sf.colossus.util.PermutationIterator<T>
-
- All Implemented Interfaces:
java.util.Iterator<java.util.List<T>>
public final class PermutationIterator<T> extends java.lang.Object implements java.util.Iterator<java.util.List<T>>An iterator that returns permutations of the originally passed list. The first permutation is the unmodified list.
-
-
Constructor Summary
Constructors Constructor Description PermutationIterator(java.util.List<T> list)Set up a permutation generator for the passed list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()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()voidremove()private voidswap(int lower)Swap elements lower and lower + 1 of permList
-
-
-
Constructor Detail
-
PermutationIterator
public PermutationIterator(java.util.List<T> list)
Set up a permutation generator for the passed list.
-
-
Method Detail
-
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.- Specified by:
hasNextin interfacejava.util.Iterator<T>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<T>
-
swap
private void swap(int lower)
Swap elements lower and lower + 1 of permList
-
-