|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.iter.AbstractIterable<R>
edu.rice.cs.plt.iter.CartesianIterable<T1,T2,R>
public class CartesianIterable<T1,T2,R>
Enumerates the elements of a cartesian (or cross) product. For each element in the
iterable left, the result of a lambda combiner, applied to that element
and each of the elements of the iterable right, is produced. Since iteration
of right occurs in an "inner loop," right must be finite (at least for
most interesting results...). The combiner function is used, rather than simply
producing Pairs, in order to provide a greater degree of flexibility.
| Constructor Summary | |
|---|---|
CartesianIterable(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
|
|
| 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()
Always false: results of a lambda may be arbitrary. |
|
CartesianIterator<T1,T2,R> |
iterator()
|
|
R |
last()
Get the last element of the list. |
|
static
|
make(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
Call the constructor (allows the type arguments to be inferred) |
|
static
|
makeSnapshot(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
Create a CartesianIterable 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 CartesianIterable(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
| Method Detail |
|---|
public CartesianIterator<T1,T2,R> iterator()
iterator in interface Iterable<R>public int compositeHeight()
Composite
compositeHeight in interface Compositepublic int compositeSize()
Composite
compositeSize in interface Compositepublic boolean isEmpty()
SizedIterable
isEmpty in interface SizedIterable<R>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<R>public int size(int bound)
SizedIterablebound, bound is returned.
size in interface SizedIterable<R>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<R>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<R>public boolean isStatic()
isStatic in interface SizedIterable<R>public R last()
OptimizedLastIterable
last in interface OptimizedLastIterable<R>
public static <T1,T2,R> CartesianIterable<T1,T2,R> make(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
public static <T1,T2,R> SnapshotIterable<R> makeSnapshot(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
CartesianIterable 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 | |||||||||