|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.iter.SequenceIterable<T>
public class SequenceIterable<T>
An iterable representing an infinite sequence. The sequence is defined by an initial
value and a successor function (described by a Lambda).
Note that the infinite nature of this list makes it impossible to use the standard equals and
hashCode implementations (in AbstractIterable). Care must
also be taken in invoking many iterable-handling methods that assume finite length,
such as those in IterUtil.
| Constructor Summary | |
|---|---|
SequenceIterable(T initial,
Lambda<? super T,? extends T> successor)
|
|
| Method Summary | ||
|---|---|---|
boolean |
equals(java.lang.Object o)
Returns true iff o is a SequenceIterable with the same initial value
and successor function (according to equals) |
|
boolean |
hasFixedSize()
true if this iterable is known to have a fixed size. |
|
int |
hashCode()
|
|
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. |
|
SequenceIterator<T> |
iterator()
Create a new SequenceIterator based on this iterable's parameters |
|
static
|
make(T initial,
Lambda<? super T,? extends T> successor)
Call the constructor (allows T to be inferred) |
|
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. |
|
java.lang.String |
toString()
Defers to IterUtil.toString(java.lang.Iterable>) |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SequenceIterable(T initial,
Lambda<? super T,? extends T> successor)
initial - The first value in the sequencesuccessor - A function that, given the nth sequence value, produces the n+1st value| Method Detail |
|---|
public SequenceIterator<T> iterator()
SequenceIterator based on this iterable's parameters
iterator in interface java.lang.Iterable<T>public boolean isEmpty()
SizedIterable
isEmpty in interface SizedIterable<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<T>public int size(int bound)
SizedIterablebound, bound is returned.
size in interface SizedIterable<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<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<T>public boolean isStatic()
isStatic in interface SizedIterable<T>public java.lang.String toString()
IterUtil.toString(java.lang.Iterable>)
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
true iff o is a SequenceIterable with the same initial value
and successor function (according to equals)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
public static <T> SequenceIterable<T> make(T initial,
Lambda<? super T,? extends T> successor)
T to be inferred)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||