|
||||||||||
| 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
|
asEnumeration(Iterator<? extends T> iter)
Make an Enumeration based on the given Iterator. |
|
static SizedIterable<Boolean> |
asIterable(boolean[] values)
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[] values)
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
|
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
|
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 v1)
Create an immutable SizedIterable containing the given values. |
|
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)
  | |