|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.iter.IterUtil
public final class IterUtil
A collection of static methods operating on iterables and iterators.
Most classes instantiated by these methods are serializable. However, since the classes generally wrap other objects, those objects must be serializable in order for serialization to succeed.
| Method Summary | ||
|---|---|---|
static
|
and(Iterable<? extends T> iter,
Predicate<? super T> pred)
Check whether the given predicate holds for all values in iter. |
|
static
|
and(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Predicate4<? super T1,? super T2,? super T3,? super T4> pred)
Check whether the given predicate holds for all corresponding values in the given iterables. |
|
static
|
and(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Predicate3<? super T1,? super T2,? super T3> pred)
Check whether the given predicate holds for all corresponding values in the given iterables. |
|
static
|
and(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Predicate2<? super T1,? super T2> pred)
Check whether the given predicate holds for all corresponding values in iter1 and iter2. |
|
static SizedIterable<?> |
arrayAsIterable(Object array)
Returns an iterable that traverses the given array, which may contain primitives or references. |
|
static SizedIterable<Boolean> |
arraySegment(boolean[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Boolean> |
arraySegment(boolean[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Byte> |
arraySegment(byte[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Byte> |
arraySegment(byte[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Character> |
arraySegment(char[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Character> |
arraySegment(char[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Double> |
arraySegment(double[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Double> |
arraySegment(double[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Float> |
arraySegment(float[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Float> |
arraySegment(float[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Integer> |
arraySegment(int[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Integer> |
arraySegment(int[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Long> |
arraySegment(long[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Long> |
arraySegment(long[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Short> |
arraySegment(short[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static SizedIterable<Short> |
arraySegment(short[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static
|
arraySegment(T[] array,
int start)
Create a SizedIterable wrapping a segment of the given array. |
|
static
|
arraySegment(T[] array,
int start,
int end)
Create a SizedIterable wrapping a segment of the given array. |
|
static
|
asEnumeration(Iterator<? extends T> iter)
Make an Enumeration based on the given Iterator. |
|
static SizedIterable<Boolean> |
asIterable(boolean[] array)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Byte> |
asIterable(byte[] values)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Character> |
asIterable(char[] array)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Character> |
asIterable(CharSequence sequence)
Create an iterable that wraps the given CharSequence. |
|
static SizedIterable<Double> |
asIterable(double[] values)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Float> |
asIterable(float[] values)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Integer> |
asIterable(int[] values)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Long> |
asIterable(long[] values)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Short> |
asIterable(short[] values)
Create a SizedIterable wrapping the given array. |
|
static SizedIterable<Character> |
asIterable(String sequence)
Create an iterable that wraps the given string. |
|
static
|
asIterable(T... array)
Create a SizedIterable wrapping the given array. |
|
static
|
asIterator(Enumeration<? extends T> en)
Make an iterator based on a (legacy-style) Enumeration. |
|
static ReadOnlyIterator<Byte> |
asIterator(InputStream in)
Make an iterator based on an InputStream. |
|
static ReadOnlyIterator<Character> |
asIterator(Reader in)
Make an iterator based on a Reader. |
|
static ReadOnlyIterator<String> |
asIterator(StringTokenizer s)
Make an iterator based on a StringTokenizer. |
|
static
|
asSizedIterable(Collection<T> coll)
Convert the given Collection to a SizedIterable. |
|
static
|
collapse(Iterable<? extends Iterable<? extends T>> iters)
Collapse a list of lists into a single list. |
|
static
|
compose(Iterable<? extends T> i1,
Iterable<? extends T> i2)
Create a ComposedIterable with the given arguments. |
|
static
|
compose(Iterable<? extends T> rest,
T last)
Create a ComposedIterable with the given arguments. |
|
static
|
compose(T first,
Iterable<? extends T> rest)
Create a ComposedIterable with the given arguments. |
|
static
|
composeLambda()
Produce a lambda that invokes compose(Object, Iterable). |
|
static
|
composeLeftLambda()
Produce a lambda that invokes compose(Object, Iterable). |
|
static
|
composeRightLambda()
Produce a lambda that invokes compose(Iterable, Object). |
|
static
|
conditionalSnapshot(Iterable<T> iter,
int threshold)
Produce a snapshot of iter if its composite size is greater than the given threshold. |
|
static boolean |
contains(Iterable<?> iter,
Object o)
Test whether the given object appears in an iteration of iter. |
|
static boolean |
containsAll(Iterable<?> iter,
Iterable<?> subset)
Test whether the given objects all appear in when iterating over iter. |
|
static boolean |
containsAny(Iterable<?> iter,
Iterable<?> candidates)
Test whether one of the given objects appears in an iteration of iter. |
|
static
|
copy(T value,
int copies)
Create a sequence containing copies instances of the given value. |
|
static
|
cross(Iterable<? extends Iterable<? extends T>> iters)
Lazily produce the cartesian (cross) product of an arbitrary number of iterables. |
|
static
|
cross(Iterable<? extends T1> left,
Iterable<? extends T2> right)
Lazily produce the cartesian (cross) product of two iterables, wrapping each combination of elements in a Pair. |
|
static
|
cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3)
Lazily produce the cartesian (cross) product of three iterables, wrapping each combination of elements in a Triple. |
|
static
|
cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4)
Lazily produce the cartesian (cross) product of four iterables, wrapping each combination of elements in a Quad. |
|
static
|
cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> combiner)
Lazily produce the cartesian (cross) product of four iterables. |
|
static
|
cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> combiner)
Lazily produce the cartesian (cross) product of three iterables. |
|
static
|
cross(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
Lazily produce the cartesian (cross) product of two iterables. |
|
static
|
crossFold(Iterable<? extends Iterable<? extends T>> iters,
R base,
Lambda2<? super R,? super T,? extends R> combiner)
Lazily apply the given folding function to each tuple in the cartesian (cross) product of the given iterables. |
|
static
|
diagonalCross(Iterable<? extends Iterable<? extends T>> iters)
Lazily produce the cartesian (cross) product of an arbitrary number of iterables. |
|
static
|
diagonalCross(Iterable<? extends T1> left,
Iterable<? extends T2> right)
Lazily produce the cartesian (cross) product of two iterables, wrapping each combination of elements in a Pair. |
|
static
|
diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3)
Lazily produce the cartesian (cross) product of three iterables, wrapping each combination of elements in a Triple. |
|
static
|
diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4)
Lazily produce the cartesian (cross) product of four iterables, wrapping each combination of elements in a Quad. |
|
static
|
diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> combiner)
Lazily produce the cartesian (cross) product of four iterables. |
|
static
|
diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> combiner)
Lazily produce the cartesian (cross) product of three iterables. |
|
static
|
diagonalCross(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
Lazily produce the cartesian (cross) product of two iterables. |
|
static
|
diagonalCrossFold(Iterable<? extends Iterable<? extends T>> iters,
R base,
Lambda2<? super R,? super T,? extends R> combiner)
Lazily apply the given folding function to each tuple in the cartesian (cross) product of the given iterables. |
|
static
|
distribute(Iterable<? extends T1> original,
Lambda<? super T1,? extends Iterable<? extends A>> breakT,
Lambda<? super Iterable<A>,? extends S2> makeS)
Use the cross(Iterable) function to lazily apply a distribution rule to the given composite
object list. |
|
static
|
distribute(S1 original,
Lambda<? super S1,? extends Iterable<? extends T1>> breakS,
Lambda<? super T1,? extends Iterable<? extends A>> breakT,
Lambda<? super Iterable<A>,? extends S2> makeS,
Lambda<? super Iterable<S2>,? extends T2> makeT)
Use the cross(Iterable) function to apply a distribution rule to the given composite object. |
|
static
|
empty()
Create an EmptyIterable; equivalent to make(). |
|
static
|
filter(Iterable<? extends T> iter,
Predicate<? super T> pred)
Produce an iterable that only contains values from the given iterable that satisfy a predicate. |
|
static
|
filterInstances(Iterable<? super T> iter,
Class<? extends T> c)
Cast all instances of the given type appropriately; filter out any non-instances. |
|
static
|
filterSnapshot(Iterable<? extends T> iter,
Predicate<? super T> pred)
Produce an iterable that only contains values from the given iterable that satisfy a predicate. |
|
static
|
finiteSequence(T initial,
Lambda<? super T,? extends T> successor,
int size)
Create a finite sequence of the given size defined by an initial value and a successor function. |
|
static
|
first(Iterable<? extends T> iter)
Access the first value in the given iterable. |
|
static
|
fold(Iterable<? extends T> iter,
R base,
Lambda2<? super R,? super T,? extends R> combiner)
Compute the left fold of the given list. |
|
static boolean |
hasFixedSize(Iterable<?> iter)
Return true iff the given iterable is known to have a fixed size. |
|
static int |
hashCode(Iterable<?> iter)
Return a hash code computed by xoring shifted copies of each element's hash code; the result is consistent with isEqual(java.lang.Iterable>, java.lang.Iterable>), but may not be consistent with
the input's equals and hashCode methods; invokes
RecurUtil#safeHashCode(Object) on each element. |
|
static
|
immutable(Iterable<? extends T> iter)
Produce an ImmutableIterable with the given iterable. |
|
static
|
infiniteSequence(T initial,
Lambda<? super T,? extends T> successor)
Create an infinite sequence defined by an initial value and a successor function. |
|
static FiniteSequenceIterable<Integer> |
integerSequence(int start,
int end)
Create a simple sequence containing the numbers between start and end
(inclusive). |
|
static boolean |
isEmpty(Iterable<?> iter)
|
|
static boolean |
isEqual(Iterable<?> iter1,
Iterable<?> iter2)
Return true iff the lists are identical (according to ==), or they
have the same size (according to sizeOf(java.lang.Iterable>)) and each corresponding element is equal
(according to LambdaUtil.EQUAL). |
|
static boolean |
isInfinite(Iterable<?> iter)
Return true iff the given iterable is known to have an infinite size. |
|
static boolean |
isStatic(Iterable<?> iter)
Return true iff the given iterable is known to be immutable. |
|
static
|
last(Iterable<? extends T> iter)
Access the last value in the given iterable. |
|
static
|
make()
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T... vals)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T[] vals,
int start)
Create an immutable SizedIterable containing the given values, from index start through the end
of the array. |
|
static
|
make(T[] vals,
int start,
int end)
Create an immutable SizedIterable containing the given values, from array index start through
end-1, inclusive (the size of the result is end-start). |
|
static
|
make(T v1,
T v2)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4,
T v5)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7,
T v8)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7,
T v8,
T v9)
Create an immutable SizedIterable containing the given values. |
|
static
|
make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7,
T v8,
T v9,
T v10)
Create an immutable SizedIterable containing the given values. |
|
static
|
makeOctet(Iterable<? extends T> iter)
Convert an iterable of 8 elements to an Octet. |
|
static
|
makeOption(Iterable<? extends T> iter)
Convert an iterable of 0 or 1 elements to an Option. |
|
static
|
makePair(Iterable<? extends T> iter)
Convert an iterable of 2 elements to a Pair. |
|
static
|
makeQuad(Iterable<? extends T> iter)
Convert an iterable of 4 elements to a Quad. |
|
static
|
makeQuint(Iterable<? extends T> iter)
Convert an iterable of 5 elements to a Quint. |
|
static
|
makeSeptet(Iterable<? extends T> iter)
Convert an iterable of 7 elements to a Septet. |
|
static
|
makeSextet(Iterable<? extends T> iter)
Convert an iterable of 6 elements to a Sextet. |
|
static
|
makeTriple(Iterable<? extends T> iter)
Convert an iterable of 3 elements to a Triple. |
|
static
|
makeWrapper(Iterable<? extends T> iter)
Convert an iterable of 1 element to a Wrapper. |
|
static
|
map(Iterable<? extends T> source,
Lambda<? super T,? extends R> map)
Lazily apply a map function to each element in an iterable. |
|
static
|
map(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> map)
Lazily apply a map function to each corresponding quadruple of elements in the given iterables. |
|
static
|
map(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> map)
Lazily apply a map function to each corresponding triple of elements in the given iterables. |
|
static
|
map(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Lambda2<? super T1,? super T2,? extends R> map)
Lazily apply a map function to each corresponding pair of elements in the given iterables. |
|
static
|
mapSnapshot(Iterable<? extends T> source,
Lambda<? super T,? extends R> map)
Immediately apply a map function to each element in an iterable. |
|
static
|
mapSnapshot(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> map)
Immediately apply a map function to each corresponding quadruple of elements in the given iterables. |
|
static
|
mapSnapshot(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> map)
Immediately apply a map function to each corresponding triple of elements in the given iterables. |
|
static
|
mapSnapshot(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Lambda2<? super T1,? super T2,? extends R> map)
Immediately apply a map function to each corresponding pair of elements in the given iterables. |
|
static String |
multilineToString(Iterable<?> iter)
Generate a string representation of the given iterable where each element is listed on a separate line. |
|
static
|
or(Iterable<? extends T> iter,
Predicate<? super T> pred)
Check whether the given predicate holds for some value in iter. |
|
static
|
or(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Predicate4<? super T1,? super T2,? super T3,? super T4> pred)
Check whether the given predicate holds for some corresponding values in the given iterables. |
|
static
|
or(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Predicate3<? super T1,? super T2,? super T3> pred)
Check whether the given predicate holds for some corresponding values in the given iterables. |
|
static
|
or(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Predicate2<? super T1,? super T2> pred)
Check whether the given predicate holds for some corresponding values in iter1 and iter2. |
|
static
|
pairFirsts(Iterable<? extends Pair<? extends T,?>> iter)
Lazily create an iterable containing the first values of the given tuples. |
|
static
|
pairSeconds(Iterable<? extends Pair<?,? extends T>> iter)
Lazily create an iterable containing the second values of the given tuples. |
|
static
|
quadFirsts(Iterable<? extends Quad<? extends T,?,?,?>> iter)
Lazily create an iterable containing the first values of the given tuples. |
|
static
|
quadFourths(Iterable<? extends Quad<?,?,?,? extends T>> iter)
Lazily create an iterable containing the fourth values of the given tuples. |
|
static
|
quadSeconds(Iterable<? extends Quad<?,? extends T,?,?>> iter)
Lazily create an iterable containing the second values of the given tuples. |
|
static
|
quadThirds(Iterable<? extends Quad<?,?,? extends T,?>> iter)
Lazily create an iterable containing the third values of the given tuples. |
|
static
|
relax(Iterable<? extends T> iter)
Allow covariance in situations where wildcards can't be used by wrapping the iterable with a less- precise type parameter. |
|
static
|
relax(Iterator<? extends T> iter)
Allow covariance in situations where wildcards can't be used by wraping the iterator with a less- precise type parameter. |
|
static
|
reverse(Iterable<? extends T> iter)
Produce a reverse-order iterable over the given elements. |
|
static
|
run(Iterable<? extends T> iter,
Runnable1<? super T> runnable)
Apply the given runnable to every element in an iterable. |
|
static
|
run(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Runnable4<? super T1,? super T2,? super T3,? super T4> runnable)
Apply the given runnable to every quadruple of corresponding elements in the given iterables. |
|
static
|
run(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Runnable3<? super T1,? super T2,? super T3> runnable)
Apply the given runnable to every triple of corresponding elements in the given iterables. |
|
static
|
run(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Runnable2<? super T1,? super T2> runnable)
Apply the given runnable to every pair of corresponding elements in the given iterables. |
|
static
|
shuffle(Iterable<T> iter)
Produce a shuffled iterable over the given elements. |
|
static
|
shuffle(Iterable<T> iter,
Random random)
Produce a shuffled iterable over the given elements, using the specified random number generator. |
|
static
|
singleton(T value)
Create a SingletonIterable; equivalent to make(Object). |
|
static int |
sizeOf(Iterable<?> iter)
Compute the size of the given iterable. |
|
static int |
sizeOf(Iterable<?> iter,
int bound)
Compute the size of the given iterable, or bound -- whichever is less. |
|
static
|
skipFirst(Iterable<T> iter)
Produce an iterable that skips the first element of iter (if it exists) |
|
static
|
skipLast(Iterable<? extends T> iter)
Produce an iterable that skips the last element of iter (if it exists). |
|
static
|
snapshot(Iterable<? extends T> iter)
Create a SnapshotIterable with the given iterable. |
|
static
|
snapshot(Iterator<? extends T> iter)
Create a SnapshotIterable with the given iterator. |
|
static
|
sort(Iterable<T> iter)
Produce a sorted iterable over the given elements. |
|
static
|
sort(Iterable<T> iter,
Comparator<? super T> comp)
Produce a sorted iterable over the given elements, using the specified comparator. |
|
static
|
split(Iterable<? extends T> iter,
int index)
Split the given iterable into two at the given index. |
|
static
|
toArray(Iterable<? extends T> iter,
Class<T> type)
Make an array with the given elements. |
|
static
|
toIterable(Octet<? extends T,? extends T,? extends T,? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Produce an iterable of size 8 from an Octet. |
|
static
|
toIterable(Option<? extends T> option)
Produce an iterable of size 0 or 1 from an Option. |
|
static
|
toIterable(Pair<? extends T,? extends T> tuple)
Produce an iterable of size 2 from a Pair. |
|
static
|
toIterable(Quad<? extends T,? extends T,? extends T,? extends T> tuple)
Produce an iterable of size 4 from a Quad. |
|
static
|
toIterable(Quint<? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Produce an iterable of size 5 from a Quint. |
|
static
|
toIterable(Septet<? extends T,? extends T,? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Produce an iterable of size 7 from a Septet. |
|
static
|
toIterable(Sextet<? extends T,? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Produce an iterable of size 6 from a Sextet. |
|
static
|
toIterable(Triple<? extends T,? extends T,? extends T> tuple)
Produce an iterable of size 3 from a Triple. |
|
static
|
toIterable(Wrapper<? extends T> tuple)
Produce an iterable of size 1 from a Wrapper. |
|
static String |
toString(Iterable<?> iter)
Generate a string representation of the given iterable, matching the Collection
conventions (results like "[foo, bar, baz]"). |
|
static String |
toString(Iterable<?> iter,
String prefix,
String delimiter,
String suffix)
Generate a string representation of the given iterable beginning with prefix, ending with
suffix, and delimited by delimiter. |
|
static
|
tripleFirsts(Iterable<? extends Triple<? extends T,?,?>> iter)
Lazily create an iterable containing the first values of the given tuples. |
|
static
|
tripleSeconds(Iterable<? extends Triple<?,? extends T,?>> iter)
Lazily create an iterable containing the second values of the given tuples. |
|
static
|
tripleThirds(Iterable<? extends Triple<?,?,? extends T>> iter)
Lazily create an iterable containing the third values of the given tuples. |
|
static
|
truncate(Iterable<? extends T> iter,
int size)
Truncate the given iterable. |
|
static
|
valuesOf(Iterable<? extends Lambda<? super T,? extends R>> iter,
T arg)
Lazily create an iterable containing the values of the application of the given lambdas. |
|
static
|
valuesOf(Iterable<? extends Lambda2<? super T1,? super T2,? extends R>> iter,
T1 arg1,
T2 arg2)
Lazily create an iterable containing the values of the application of the given lambdas. |
|
static
|
valuesOf(Iterable<? extends Lambda3<? super T1,? super T2,? super T3,? extends R>> iter,
T1 arg1,
T2 arg2,
T3 arg3)
Lazily create an iterable containing the values of the application of the given lambdas. |
|
static
|
valuesOf(Iterable<? extends Thunk<? extends R>> iter)
Lazily create an iterable containing the values of the given thunks. |
|
static
|
zip(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2)
Lazily create an iterable of Pairs of corresponding values from the given iterables (assumed to always
have the same length). |
|
static
|
zip(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3)
Lazily create an iterable of Triples of corresponding values from the given iterables (assumed to
always have the same length). |
|
static
|
zip(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4)
Lazily create an iterable of Quads of corresponding values from the given iterables (assumed to
always have the same length). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isEmpty(Iterable<?> iter)
true iff the given iterable contains no elementspublic static int sizeOf(Iterable<?> iter)
iter is a SizedIterable or a
Collection), this is a potentially constant-time operation; otherwise, it is linear in the size of
iter (if iter is infinite in this case, this method will loop Integer.MAX_VALUE times
before returning).
public static int sizeOf(Iterable<?> iter,
int bound)
bound -- whichever is less. This allows a size to be
computed where the iterable may be infinite. Where possible (when iter is a SizedIterable
or a Collection), this is a potentially constant-time operation; otherwise, it is linear in the size
of iter or bound (whichever is smaller).
public static boolean isInfinite(Iterable<?> iter)
true iff the given iterable is known to have an infinite size.
SizedIterable.isInfinite()public static boolean hasFixedSize(Iterable<?> iter)
true iff the given iterable is known to have a fixed size. Infinite iterables are considered
fixed if they will never become finite.
SizedIterable.hasFixedSize()public static boolean isStatic(Iterable<?> iter)
true iff the given iterable is known to be immutable.
SizedIterable.isStatic()
public static boolean contains(Iterable<?> iter,
Object o)
iter. Uses the
Collection.contains(java.lang.Object) method where possible; otherwise, may take linear time.
public static boolean containsAll(Iterable<?> iter,
Iterable<?> subset)
iter. Uses the
Collection.containsAll(java.util.Collection>) and Collection.contains(java.lang.Object) methods where possible;
otherwise, may take quadratic time.
CollectUtil.containsAll(java.util.Collection>, java.lang.Iterable>),
and(java.lang.Iterable extends T>, edu.rice.cs.plt.lambda.Predicate super T>)
public static boolean containsAny(Iterable<?> iter,
Iterable<?> candidates)
iter. Uses the
Collection.contains(java.lang.Object) method where possible; otherwise, may take quadratic time.
or(java.lang.Iterable extends T>, edu.rice.cs.plt.lambda.Predicate super T>)public static String toString(Iterable<?> iter)
Collection
conventions (results like "[foo, bar, baz]"). Invokes
RecurUtil.safeToString(Object) on each element. If the iterable is known to be
infinite (isInfinite(java.lang.Iterable>)), the string contains a few elements followed by "...".
public static String multilineToString(Iterable<?> iter)
RecurUtil.safeToString(Object) on each element. If the iterable
is known to be infinite (isInfinite(java.lang.Iterable>)), the string contains a few elements followed by
"...".
public static String toString(Iterable<?> iter,
String prefix,
String delimiter,
String suffix)
prefix, ending with
suffix, and delimited by delimiter. Invokes RecurUtil.safeToString(Object)
on each element. If the iterable is known to be infinite (isInfinite(java.lang.Iterable>)), the string contains
a few elements followed by "...".
public static boolean isEqual(Iterable<?> iter1,
Iterable<?> iter2)
true iff the lists are identical (according to ==), or they
have the same size (according to sizeOf(java.lang.Iterable>)) and each corresponding element is equal
(according to LambdaUtil.EQUAL). Assumes that at least one of the iterables is finite.
public static int hashCode(Iterable<?> iter)
isEqual(java.lang.Iterable>, java.lang.Iterable>), but may not be consistent with
the input's equals and hashCode methods; invokes
RecurUtil#safeHashCode(Object) on each element. Assumes the iterable is finite.
public static <T> ReadOnlyIterator<T> asIterator(Enumeration<? extends T> en)
Enumeration. If an Iterable is
needed (rather than an Iterator), the result can be wrapped in a
ReadOnceIterable.
public static ReadOnlyIterator<String> asIterator(StringTokenizer s)
StringTokenizer. (This is similar to
asIterator(Enumeration), but allows the tokenizer to be treated as an enumeration
of Strings rather than, as defined, an enumeration of Objects.) If an
Iterable is needed (rather than an Iterator), the result can be wrapped in a
ReadOnceIterable.
public static ReadOnlyIterator<Character> asIterator(Reader in)
Reader. If an IOException
occurs while reading, an IllegalStateException is thrown. If an
Iterable is needed (rather than an Iterator), the result
can be wrapped in a ReadOnceIterable.
public static ReadOnlyIterator<Byte> asIterator(InputStream in)
InputStream. If an IOException
occurs while reading, an IllegalStateException is thrown. If an
Iterable is needed (rather than an Iterator), the result
can be wrapped in a ReadOnceIterable.
public static <T> Enumeration<T> asEnumeration(Iterator<? extends T> iter)
Enumeration based on the given Iterator. For compatibility with legacy APIs.
public static <T> EmptyIterable<T> empty()
EmptyIterable; equivalent to make().
public static <T> SingletonIterable<T> singleton(T value)
SingletonIterable; equivalent to make(Object).
public static <T> ComposedIterable<T> compose(T first,
Iterable<? extends T> rest)
ComposedIterable with the given arguments.
public static <T> Lambda2<T,Iterable<? extends T>,Iterable<T>> composeLeftLambda()
compose(Object, Iterable).
public static <T> ComposedIterable<T> compose(Iterable<? extends T> rest,
T last)
ComposedIterable with the given arguments.
public static <T> Lambda2<Iterable<? extends T>,T,Iterable<T>> composeRightLambda()
compose(Iterable, Object).
public static <T> ComposedIterable<T> compose(Iterable<? extends T> i1,
Iterable<? extends T> i2)
ComposedIterable with the given arguments.
public static <T> Lambda2<Iterable<? extends T>,Iterable<? extends T>,Iterable<T>> composeLambda()
compose(Object, Iterable).
public static <T> SnapshotIterable<T> snapshot(Iterable<? extends T> iter)
SnapshotIterable with the given iterable.
public static <T> SnapshotIterable<T> snapshot(Iterator<? extends T> iter)
SnapshotIterable with the given iterator.
public static <T> Iterable<T> conditionalSnapshot(Iterable<T> iter,
int threshold)
iter if its composite size is greater than the given threshold.
ObjectUtil.compositeSize(java.lang.Object)public static <T> ImmutableIterable<T> immutable(Iterable<? extends T> iter)
ImmutableIterable with the given iterable.
public static <T> SizedIterable<T> relax(Iterable<? extends T> iter)
public static <T> Iterator<T> relax(Iterator<? extends T> iter)
public static <T> SizedIterable<T> make()
public static <T> SizedIterable<T> make(T v1)
public static <T> SizedIterable<T> make(T v1,
T v2)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4,
T v5)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7,
T v8)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7,
T v8,
T v9)
public static <T> SizedIterable<T> make(T v1,
T v2,
T v3,
T v4,
T v5,
T v6,
T v7,
T v8,
T v9,
T v10)
public static <T> SizedIterable<T> make(T... vals)
vals can be mutated by the caller). Note that restrictions on array
creation may lead to errors or warnings at the invocation site where T is a non-reifiable type.
public static <T> SizedIterable<T> make(T[] vals,
int start)
start through the end
of the array. Requires linear time to make a copy (necessary because vals can be mutated by the
caller).
public static <T> SizedIterable<T> make(T[] vals,
int start,
int end)
start through
end-1, inclusive (the size of the result is end-start). Requires linear time to make a
copy (necessary because vals can be mutated by the caller).
public static <T> SequenceIterable<T> infiniteSequence(T initial,
Lambda<? super T,? extends T> successor)
public static <T> FiniteSequenceIterable<T> finiteSequence(T initial,
Lambda<? super T,? extends T> successor,
int size)
public static FiniteSequenceIterable<Integer> integerSequence(int start,
int end)
start and end
(inclusive). start may be less than or greater than end (or even
equal to it); the resulting iterator will increment or decrement as necessary.
public static <T> FiniteSequenceIterable<T> copy(T value,
int copies)
copies instances of the given value.
public static <T> SizedIterable<T> asIterable(T... array)
make(Object[]).)
public static <T> SizedIterable<T> arraySegment(T[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, make a copy instead with make(Object[], int).)
IndexOutOfBoundsException - If start is an invalid index.
public static <T> SizedIterable<T> arraySegment(T[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, make a copy instead with
make(Object[], int, int).)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Boolean> asIterable(boolean[] array)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Boolean> arraySegment(boolean[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Boolean> arraySegment(boolean[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Character> asIterable(char[] array)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Character> arraySegment(char[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Character> arraySegment(char[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Byte> asIterable(byte[] values)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Byte> arraySegment(byte[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Byte> arraySegment(byte[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Short> asIterable(short[] values)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Short> arraySegment(short[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Short> arraySegment(short[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Integer> asIterable(int[] values)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Integer> arraySegment(int[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Integer> arraySegment(int[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Long> asIterable(long[] values)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Long> arraySegment(long[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Long> arraySegment(long[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Float> asIterable(float[] values)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Float> arraySegment(float[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Float> arraySegment(float[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<Double> asIterable(double[] values)
snapshot(Iterable) may be invoked on the result.)
public static SizedIterable<Double> arraySegment(double[] array,
int start)
start through the
end of the array are included. Subsequent changes to the array will be reflected in the result; also note
that entire array will remain in memory until references to this segment are discarded. (To prevent mutation
and potential memory leaks, snapshot(Iterable) may be invoked on the result.)
IndexOutOfBoundsException - If start is an invalid index.
public static SizedIterable<Double> arraySegment(double[] array,
int start,
int end)
start through
end-1 are included (and the size is thus end-start). Subsequent changes to the array
will be reflected in the result; also note that entire array will remain in memory until references to
this segment are discarded. (To prevent mutation and potential memory leaks, snapshot(Iterable)
may be invoked on the result.)
IndexOutOfBoundsException - If start and end are inconsistent with each other or
with the length of the array.public static SizedIterable<?> arrayAsIterable(Object array)
IllegalArgumentException - If array is not an arraypublic static <T> SizedIterable<T> asSizedIterable(Collection<T> coll)
Collection to a SizedIterable. If it already is
a SizedIterable, cast it as such. Otherwise, wrap it. In either case, subsequent
changes made to the collection will be reflected in the result (if this is not the desired
behavior, snapshot(Iterable) can be used instead).
public static SizedIterable<Character> asIterable(CharSequence sequence)
CharSequence.
public static SizedIterable<Character> asIterable(String sequence)
asIterable(CharSequence),
but takes advantage of the fact that Strings are immutable.
public static <T> SizedIterable<T> toIterable(Option<? extends T> option)
Option.
public static <T> SizedIterable<T> toIterable(Wrapper<? extends T> tuple)
Wrapper.
public static <T> SizedIterable<T> toIterable(Pair<? extends T,? extends T> tuple)
Pair.
public static <T> SizedIterable<T> toIterable(Triple<? extends T,? extends T,? extends T> tuple)
Triple.
public static <T> SizedIterable<T> toIterable(Quad<? extends T,? extends T,? extends T,? extends T> tuple)
Quad.
public static <T> SizedIterable<T> toIterable(Quint<? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Quint.
public static <T> SizedIterable<T> toIterable(Sextet<? extends T,? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Sextet.
public static <T> SizedIterable<T> toIterable(Septet<? extends T,? extends T,? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Septet.
public static <T> SizedIterable<T> toIterable(Octet<? extends T,? extends T,? extends T,? extends T,? extends T,? extends T,? extends T,? extends T> tuple)
Octet.
public static <T> T[] toArray(Iterable<? extends T> iter,
Class<T> type)
Collection.toArray() method where possible; otherwise, just iterates through
iter to fill the array. If the size of the iterable is larger than Integer.MAX_VALUE
or is infinite, it will be truncated to fit in an array.
public static <T> T first(Iterable<? extends T> iter)
NoSuchElementException - If the iterable is emptypublic static <T> SkipFirstIterable<T> skipFirst(Iterable<T> iter)
iter (if it exists)
public static <T> T last(Iterable<? extends T> iter)
OptimizedLastIterables, SortedSets, or Lists), this operation takes time on
the order of the length of the list. Assumes the iterable is finite.
NoSuchElementException - If the iterable is emptypublic static <T> SkipLastIterable<T> skipLast(Iterable<? extends T> iter)
iter (if it exists). Assumes the iterable
is finite.
public static <T> Option<T> makeOption(Iterable<? extends T> iter)
Option.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Wrapper<T> makeWrapper(Iterable<? extends T> iter)
Wrapper.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Pair<T,T> makePair(Iterable<? extends T> iter)
Pair.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Triple<T,T,T> makeTriple(Iterable<? extends T> iter)
Triple.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Quad<T,T,T,T> makeQuad(Iterable<? extends T> iter)
Quad.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Quint<T,T,T,T,T> makeQuint(Iterable<? extends T> iter)
Quint.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Sextet<T,T,T,T,T,T> makeSextet(Iterable<? extends T> iter)
Sextet.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Septet<T,T,T,T,T,T,T> makeSeptet(Iterable<? extends T> iter)
Septet.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> Octet<T,T,T,T,T,T,T,T> makeOctet(Iterable<? extends T> iter)
Octet.
IllegalArgumentException - If the iterable is not of the appropriate size.public static <T> SizedIterable<T> reverse(Iterable<? extends T> iter)
iter will not
be reflected in the result. Runs in linear time.
public static <T> SizedIterable<T> shuffle(Iterable<T> iter)
iter will not
be reflected in the result. Runs in linear time.
public static <T> SizedIterable<T> shuffle(Iterable<T> iter,
Random random)
iter will not be reflected in the result. Runs in linear time.
public static <T extends Comparable<? super T>> SizedIterable<T> sort(Iterable<T> iter)
iter will not
be reflected in the result. Runs in n log n time.
public static <T> SizedIterable<T> sort(Iterable<T> iter,
Comparator<? super T> comp)
iter will not be reflected in the result. Runs in n log n time.
public static <T> Pair<SizedIterable<T>,SizedIterable<T>> split(Iterable<? extends T> iter,
int index)
index values in
iter will belong to the first half; the rest will belong to the second half.
Where there are less than index values in iter, the first half will contain
them all and the second half will be empty. Note that the result is a snapshot — later
modifications to iter will not be reflected. Assumes the iterable is finite.
public static <T> TruncatedIterable<T> truncate(Iterable<? extends T> iter,
int size)
size. Subsequent
changes to iter will be reflected in the result.
public static <T> CollapsedIterable<T> collapse(Iterable<? extends Iterable<? extends T>> iters)
iter or its sublists
will be reflected in the result.
public static <T> FilteredIterable<T> filter(Iterable<? extends T> iter,
Predicate<? super T> pred)
public static <T> SnapshotIterable<T> filterSnapshot(Iterable<? extends T> iter,
Predicate<? super T> pred)
public static <T> FilteredIterable<T> filterInstances(Iterable<? super T> iter,
Class<? extends T> c)
public static <T,R> R fold(Iterable<? extends T> iter,
R base,
Lambda2<? super R,? super T,? extends R> combiner)
# (written here
with infix notation), compute base # iter.next() # iter.next() # .... Assumes the iterable is finite.
public static <T> boolean and(Iterable<? extends T> iter,
Predicate<? super T> pred)
iter. Computation halts immediately where the
predicate fails. May never halt if the iterable is infinite.
public static <T> boolean or(Iterable<? extends T> iter,
Predicate<? super T> pred)
iter. Computation halts immediately where the
predicate succeeds. May never halt if the interable is infinite.
public static <T1,T2> boolean and(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Predicate2<? super T1,? super T2> pred)
iter1 and iter2. The
iterables are assumed to have the same length; computation halts immediately where the predicate fails.
May never halt if the iterables are infinite.
public static <T1,T2> boolean or(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Predicate2<? super T1,? super T2> pred)
iter1 and iter2. The
iterables are assumed to have the same length; computation halts immediately where the predicate succeeds.
May never halt if the iterables are infinite.
public static <T1,T2,T3> boolean and(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Predicate3<? super T1,? super T2,? super T3> pred)
public static <T1,T2,T3> boolean or(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Predicate3<? super T1,? super T2,? super T3> pred)
public static <T1,T2,T3,T4> boolean and(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Predicate4<? super T1,? super T2,? super T3,? super T4> pred)
public static <T1,T2,T3,T4> boolean or(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Predicate4<? super T1,? super T2,? super T3,? super T4> pred)
public static <T,R> SizedIterable<R> map(Iterable<? extends T> source,
Lambda<? super T,? extends R> map)
public static <T,R> SnapshotIterable<R> mapSnapshot(Iterable<? extends T> source,
Lambda<? super T,? extends R> map)
public static <T1,T2,R> SizedIterable<R> map(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Lambda2<? super T1,? super T2,? extends R> map)
public static <T1,T2,R> SnapshotIterable<R> mapSnapshot(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Lambda2<? super T1,? super T2,? extends R> map)
public static <T1,T2,T3,R> SizedIterable<R> map(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> map)
public static <T1,T2,T3,R> SnapshotIterable<R> mapSnapshot(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> map)
public static <T1,T2,T3,T4,R> SizedIterable<R> map(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> map)
public static <T1,T2,T3,T4,R> SnapshotIterable<R> mapSnapshot(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> map)
public static <T> void run(Iterable<? extends T> iter,
Runnable1<? super T> runnable)
public static <T1,T2> void run(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Runnable2<? super T1,? super T2> runnable)
public static <T1,T2,T3> void run(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Runnable3<? super T1,? super T2,? super T3> runnable)
public static <T1,T2,T3,T4> void run(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Runnable4<? super T1,? super T2,? super T3,? super T4> runnable)
public static <T1,T2,R> SizedIterable<R> cross(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
CartesianIterable.
public static <T1,T2> SizedIterable<Pair<T1,T2>> cross(Iterable<? extends T1> left,
Iterable<? extends T2> right)
Pair. The order of results is defined by CartesianIterable.
public static <T1,T2,R> SizedIterable<R> diagonalCross(Iterable<? extends T1> left,
Iterable<? extends T2> right,
Lambda2<? super T1,? super T2,? extends R> combiner)
DiagonalCartesianIterable.
public static <T1,T2> SizedIterable<Pair<T1,T2>> diagonalCross(Iterable<? extends T1> left,
Iterable<? extends T2> right)
Pair. The order of results is defined by DiagonalCartesianIterable.
public static <T1,T2,T3,R> SizedIterable<R> cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> combiner)
CartesianIterable.
public static <T1,T2,T3> SizedIterable<Triple<T1,T2,T3>> cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3)
Triple. The order of results is defined by CartesianIterable.
public static <T1,T2,T3,R> SizedIterable<R> diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Lambda3<? super T1,? super T2,? super T3,? extends R> combiner)
DiagonalCartesianIterable.
public static <T1,T2,T3> SizedIterable<Triple<T1,T2,T3>> diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3)
Triple. The order of results is defined by DiagonalCartesianIterable.
public static <T1,T2,T3,T4,R> SizedIterable<R> cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> combiner)
CartesianIterable.
public static <T1,T2,T3,T4> SizedIterable<Quad<T1,T2,T3,T4>> cross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4)
Quad. The order of results is defined by CartesianIterable.
public static <T1,T2,T3,T4,R> SizedIterable<R> diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4,
Lambda4<? super T1,? super T2,? super T3,? super T4,? extends R> combiner)
DiagonalCartesianIterable.
public static <T1,T2,T3,T4> SizedIterable<Quad<T1,T2,T3,T4>> diagonalCross(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4)
Quad. The order of results is defined by DiagonalCartesianIterable.
public static <T> SizedIterable<Iterable<T>> cross(Iterable<? extends Iterable<? extends T>> iters)
iters is empty, the result is a single empty iterable.
The order of results is defined by CartesianIterable. The input iterable is assumed to be finite;
the elements of this list, on the other hand, need not be.
public static <T> SizedIterable<Iterable<T>> diagonalCross(Iterable<? extends Iterable<? extends T>> iters)
iters is empty, the result is a single empty iterable.
The order of results is defined by DiagonalCartesianIterable. The input iterable is assumed
to be finite; the elements of this list, on the other hand, need not be.
public static <T,R> SizedIterable<R> crossFold(Iterable<? extends Iterable<? extends T>> iters,
R base,
Lambda2<? super R,? super T,? extends R> combiner)
CartesianIterable. The input iterable is assumed
to be finite; the elements of this list, on the other hand, need not be.
public static <T,R> SizedIterable<R> diagonalCrossFold(Iterable<? extends Iterable<? extends T>> iters,
R base,
Lambda2<? super R,? super T,? extends R> combiner)
DiagonalCartesianIterable. The input iterable is assumed
to be finite; the elements of this list, on the other hand, need not be.
public static <T1,A,S2> Iterable<S2> distribute(Iterable<? extends T1> original,
Lambda<? super T1,? extends Iterable<? extends A>> breakT,
Lambda<? super Iterable<A>,? extends S2> makeS)
cross(Iterable) function to lazily apply a distribution rule to the given composite
object list. Given a list of conjunctions, for example, this method transforms the list into an
equivalent list of disjunctions.
T1 - The original object's components, each composed of As.A - The type of atomic components of a T1 or S2.S2 - The type of the result's components, again composed of As.original - A list of original T1s.breakT - Decomposes a T1 into its constituent elements.makeS - Construct an S2 from the given elements.
public static <S1,T1,A,S2,T2> T2 distribute(S1 original,
Lambda<? super S1,? extends Iterable<? extends T1>> breakS,
Lambda<? super T1,? extends Iterable<? extends A>> breakT,
Lambda<? super Iterable<A>,? extends S2> makeS,
Lambda<? super Iterable<S2>,? extends T2> makeT)
cross(Iterable) function to apply a distribution rule to the given composite object.
Given constructors $ and %, for example, this method transforms an object of the form
(a$b) % (c$d$e) to (a%c) $ (a%d) $ (a%e) $ (b%c) $ (b%d) $ (b%e). For maximum flexibility,
the types produced by the $ and % constructors may be different from each other and from
the type of atomic elements. Additionally, the type of $ applied to some %-constructed
elements may be different than the type of $ applied to atomic elements (and the same for %).
S1 - The original object type, composed of T1s.T1 - The type of S1's components, composed of As.A - The type of atomic components of a T1 or S2.S2 - The type of a T2's components in the result, composed of As.T2 - The result type, composed of S2s.original - The original objectbreakS - Decomposes an S1 into its constituent elements.breakT - Decomposes a T1 into its constituent elements.makeS - Construct an S2 from the given elements.makeT - Construct a T2 from the given elements.public static <R> SizedIterable<R> valuesOf(Iterable<? extends Thunk<? extends R>> iter)
public static <T,R> Iterable<R> valuesOf(Iterable<? extends Lambda<? super T,? extends R>> iter,
T arg)
public static <T1,T2,R> SizedIterable<R> valuesOf(Iterable<? extends Lambda2<? super T1,? super T2,? extends R>> iter,
T1 arg1,
T2 arg2)
public static <T1,T2,T3,R> SizedIterable<R> valuesOf(Iterable<? extends Lambda3<? super T1,? super T2,? super T3,? extends R>> iter,
T1 arg1,
T2 arg2,
T3 arg3)
public static <T> SizedIterable<T> pairFirsts(Iterable<? extends Pair<? extends T,?>> iter)
public static <T> SizedIterable<T> pairSeconds(Iterable<? extends Pair<?,? extends T>> iter)
public static <T> SizedIterable<T> tripleFirsts(Iterable<? extends Triple<? extends T,?,?>> iter)
public static <T> SizedIterable<T> tripleSeconds(Iterable<? extends Triple<?,? extends T,?>> iter)
public static <T> SizedIterable<T> tripleThirds(Iterable<? extends Triple<?,?,? extends T>> iter)
public static <T> SizedIterable<T> quadFirsts(Iterable<? extends Quad<? extends T,?,?,?>> iter)
public static <T> SizedIterable<T> quadSeconds(Iterable<? extends Quad<?,? extends T,?,?>> iter)
public static <T> SizedIterable<T> quadThirds(Iterable<? extends Quad<?,?,? extends T,?>> iter)
public static <T> SizedIterable<T> quadFourths(Iterable<? extends Quad<?,?,?,? extends T>> iter)
public static <T1,T2> SizedIterable<Pair<T1,T2>> zip(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2)
Pairs of corresponding values from the given iterables (assumed to always
have the same length). Useful for simultaneous iteration of multiple lists in a for loop.
public static <T1,T2,T3> SizedIterable<Triple<T1,T2,T3>> zip(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3)
Triples of corresponding values from the given iterables (assumed to
always have the same length). Useful for simultaneous iteration of multiple lists in a for loop.
public static <T1,T2,T3,T4> SizedIterable<Quad<T1,T2,T3,T4>> zip(Iterable<? extends T1> iter1,
Iterable<? extends T2> iter2,
Iterable<? extends T3> iter3,
Iterable<? extends T4> iter4)
Quads of corresponding values from the given iterables (assumed to
always have the same length). Useful for simultaneous iteration of multiple lists in a for loop.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||