edu.rice.cs.plt.iter
Class PermutationIterator<T>

java.lang.Object
  extended by edu.rice.cs.plt.iter.ReadOnlyIterator<java.lang.Iterable<T>>
      extended by edu.rice.cs.plt.iter.PermutationIterator<T>
Type Parameters:
T - The element type of the permuted lists; note that next() returns Iterable<T>s, not Ts.
All Implemented Interfaces:
java.util.Iterator<java.lang.Iterable<T>>

public class PermutationIterator<T>
extends ReadOnlyIterator<java.lang.Iterable<T>>

Enumerates all permutations of the given list. Behavior is undefined if the given list changes during iteration. The size of the enumeration, where the original list has size n, is n! (and is thus guaranteed to be >= 1). The order of the results is lexicographical, assuming each element of the original list is taken to lexicographically precede all of its successors. (Thus, the original list is the first to be returned, and a reversed list is the last.) Of course, due to the factorial complexity of enumerating all permutations, this class is probably not suitable for applications in which n is unbounded (or just intractably large).


Constructor Summary
PermutationIterator(java.lang.Iterable<? extends T> original)
           
 
Method Summary
 boolean hasNext()
           
static
<T> PermutationIterator<T>
make(java.lang.Iterable<? extends T> original)
          Call the constructor (allows T to be inferred)
 java.lang.Iterable<T> next()
           
 
Methods inherited from class edu.rice.cs.plt.iter.ReadOnlyIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermutationIterator

public PermutationIterator(java.lang.Iterable<? extends T> original)
Method Detail

hasNext

public boolean hasNext()

next

public java.lang.Iterable<T> next()

make

public static <T> PermutationIterator<T> make(java.lang.Iterable<? extends T> original)
Call the constructor (allows T to be inferred)