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 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
-
-
-
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:
hasNext
in interfacejava.util.Iterator<T>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<T>
-
swap
private void swap(int lower)
Swap elements lower and lower + 1 of permList
-
-