net.sourceforge.nite.search
Class ListPermuteIterator

java.lang.Object
  extended by net.sourceforge.nite.search.ListPermuteIterator
All Implemented Interfaces:
java.util.Iterator

public class ListPermuteIterator
extends java.lang.Object
implements java.util.Iterator

ListPermuteIterator implement an Iterator to walk through all permutations of the given list. I.e. next() of a new ListPermuteIterator( {a, b, c} ) will visit these lists:
{a, b, c}
{a, c, b}
{b, a, c}
{b, c, a}
{c, a, b}
{c, b, a}.


Constructor Summary
ListPermuteIterator(java.util.List list)
          Creates a new Iterator to walk through all permutations of the given list.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more permutations.
 java.lang.Object next()
          Returns the next permutation in the iteration.
 void remove()
          The remove operation is not supported by this Iterator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListPermuteIterator

public ListPermuteIterator(java.util.List list)
Creates a new Iterator to walk through all permutations of the given list.

Parameters:
list - the list to permutate
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more permutations. (In other words, returns true if next() would return an element rather than throwing an exception.)

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if the iteration has more permutations

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Returns the next permutation in the iteration.

Specified by:
next in interface java.util.Iterator
Returns:
the next permutation in the iteration
Throws:
java.util.NoSuchElementException - there are no more permutations

remove

public void remove()
The remove operation is not supported by this Iterator.

Specified by:
remove in interface java.util.Iterator