|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.iter.AbstractIterable<java.lang.Iterable<T>>
edu.rice.cs.plt.iter.PermutationIterable<T>
T - The element type of the permuted lists; note that the iterator returns
Iterable<T>s, not Ts.public class PermutationIterable<T>
An enumeration of all permutations of the given list. 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" where 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 | |
|---|---|
PermutationIterable(java.lang.Iterable<? extends T> original)
|
|
| Method Summary | ||
|---|---|---|
int |
compositeHeight()
Get the maximum path length from this node to a leaf. |
|
int |
compositeSize()
Get the number of nodes in the tree rooted at this node. |
|
boolean |
hasFixedSize()
true if this iterable is known to have a fixed size. |
|
boolean |
isEmpty()
Whether the iterable does not contain any elements. |
|
boolean |
isInfinite()
true if the iterable is known to have infinite size. |
|
boolean |
isStatic()
true if this iterable is unchanging. |
|
PermutationIterator<T> |
iterator()
|
|
java.lang.Iterable<T> |
last()
Get the last element of the list. |
|
static
|
make(java.lang.Iterable<? extends T> original)
Call the constructor (allows T to be inferred) |
|
static
|
makeSnapshot(java.lang.Iterable<? extends T> original)
Create a PermutationIterable and wrap it in a SnapshotIterable, forcing
immediate evaluation of the permutations. |
|
int |
size()
Compute the number of elements in the iterable. |
|
int |
size(int bound)
Compute the number of elements in the iterable, up to the given bound. |
|
| Methods inherited from class edu.rice.cs.plt.iter.AbstractIterable |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PermutationIterable(java.lang.Iterable<? extends T> original)
| Method Detail |
|---|
public PermutationIterator<T> iterator()
iterator in interface java.lang.Iterable<java.lang.Iterable<T>>public int compositeHeight()
Composite
compositeHeight in interface Compositepublic int compositeSize()
Composite
compositeSize in interface Compositepublic boolean isEmpty()
SizedIterable
isEmpty in interface SizedIterable<java.lang.Iterable<T>>public int size()
SizedIterableint, Integer.MAX_VALUE should be returned. Otherwise, next() may be safely invoked
on the iterator exactly this number of times.
size in interface SizedIterable<java.lang.Iterable<T>>public int size(int bound)
SizedIterablebound, bound is returned.
size in interface SizedIterable<java.lang.Iterable<T>>bound - Maximum result. Assumed to be nonnegative.public boolean isInfinite()
SizedIterabletrue if the iterable is known to have infinite size. If true, an iterator over the iterable in its
current state will never return false from hasNext().
isInfinite in interface SizedIterable<java.lang.Iterable<T>>public boolean hasFixedSize()
SizedIterabletrue if this iterable is known to have a fixed size. This is the case if the iterable is immutable,
or if changes can only replace values, not remove or add them. An infinite iterable may be fixed if it
is guaranteed to never become finite.
hasFixedSize in interface SizedIterable<java.lang.Iterable<T>>public boolean isStatic()
SizedIterabletrue if this iterable is unchanging. This implies that hasFixedSize() is true, and that
iterator() will always return the same (either == or equal() and immutable) elements
in the same order. ("Immutable" here means that equals() invocations are consistent over time -- if
two objects are equal, they will never become inequal, and vice versa.)
isStatic in interface SizedIterable<java.lang.Iterable<T>>public java.lang.Iterable<T> last()
OptimizedLastIterable
last in interface OptimizedLastIterable<java.lang.Iterable<T>>public static <T> PermutationIterable<T> make(java.lang.Iterable<? extends T> original)
T to be inferred)
public static <T> SnapshotIterable<java.lang.Iterable<T>> makeSnapshot(java.lang.Iterable<? extends T> original)
PermutationIterable and wrap it in a SnapshotIterable, forcing
immediate evaluation of the permutations.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||