| java.lang.Object net.sf.jga.util.Iterables
Iterables | public class Iterables (Code) | | Facade for the Iterators in this package, supporting the new forloop syntax.
Only iterators that perform their service during the hasNext()/next()
sequence are given in this facade. Iterators that augment to the basic
Iterator interface, (e.g., CachingIterator) are not included.
Copyright © 2004-2005 David A. Hall
author: David A. Hall |
Method Summary | |
public static boolean | addAll(Collection<? super T> cout, Iterable<T> iter) Adds all of the elements of the iterable to the collection. | public static boolean | addAll(Collection<? super T> cout, T[] ts) Adds all of the elements of the array to the collection. | public static Collection<? super T> | append(Collection<? super T> cout, Iterable<T> iter) Adds all of the elements of the iterable to the collection, and returns
the collection. | public static Collection<? super T> | append(Collection<? super T> cout, T[] ts) Adds all of the elements of the array to the collection and returns the
collection. | public static Iterable<T> | filter(Iterable<? extends T> i, UnaryFunctor<T, Boolean> pred) | public static Iterable<T> | filter(T[] ts, UnaryFunctor<T, Boolean> pred) | public static Iterable<Iterator<? extends T>> | findAll(Iterable<? extends T> i, UnaryFunctor<Iterator<? extends T>, ? extends Iterator<T>> fn) Returns iterators that point to the next instance in an iterable that
meets the condition described in the functor. | public static Iterable<Iterator<? extends T>> | findAll(T[] ts, UnaryFunctor<Iterator<? extends T>, ? extends Iterator<T>> fn) Returns iterators that point to the next instance in an iterable that
meets the condition described in the functor. | public static Iterable<T> | merge(Iterable<? extends T> i1, Iterable<? extends T> i2) Returns all elements of both iterables, always choosing the lesser of the
two current elements. | public static Iterable<T> | merge(T[] ts1, T[] ts2) Returns all elements of both arrays, always choosing the lesser of the
two current elements. | public static Iterable<T> | merge(Iterable<? extends T> i1, Iterable<? extends T> i2, Comparator<T> comp) Returns all elements of both iterables, always choosing the lesser of the
two current elements. | public static Iterable<T> | merge(T[] ts1, T[] ts2, Comparator<T> comp) Returns all elements of both arrays, always choosing the lesser of the
two current elements. | public static Iterable<T> | merge(Iterable<? extends T> i1, Iterable<? extends T> i2, BinaryFunctor<T, T, Boolean> fn) Returns all elements of both iterables, using the given predicate to
choose which element to return. | public static Iterable<T> | merge(T[] ts1, T[] ts2, BinaryFunctor<T, T, Boolean> fn) Returns all elements of both arrays, using the given predicate to
choose which element to return. | public static Iterable<R> | transform(Iterable<? extends T> i, UnaryFunctor<T, R> fn) Returns the results of applying the given functor to each element in turn. | public static Iterable<R> | transform(T[] ts, UnaryFunctor<T, R> fn) Returns the results of applying the given functor to each element in turn. | public static Iterable<R> | transform(Iterable<? extends T1> i1, Iterable<? extends T2> i2, BinaryFunctor<T1, T2, R> fn) Returns the results of applying the given functor to corresponding elements. | public static Iterable<R> | transform(T1[] ts1, T2[] ts2, BinaryFunctor<T1, T2, R> fn) Returns the results of applying the given functor to corresponding elements. | public static Iterable<R> | transform(Iterable<? extends T> i, BinaryFunctor<T, T, R> fn) Returns the results of applying the given functor to succesive pairs of elements. | public static Iterable<R> | transform(T[] ts, BinaryFunctor<T, T, R> fn) Returns the results of applying the given functor to succesive pairs of elements. | public static Iterable<T> | unique(Iterable<? extends T> i) Returns unduplicated results: will not return the same value twice in
succession. | public static Iterable<T> | unique(T[] ts) Returns unduplicated results: will not return the same value twice in
succession. | public static Iterable<T> | unique(Iterable<? extends T> i, BinaryFunctor<T, T, Boolean> eq) Returns unduplicated results: will not return the same value twice in
succession, as determined by the given predicate. | public static Iterable<T> | unique(T[] ts, BinaryFunctor<T, T, Boolean> eq) Returns unduplicated results: will not return the same value twice in
succession, as determined by the given predicate. |
addAll | public static boolean addAll(Collection<? super T> cout, Iterable<T> iter)(Code) | | Adds all of the elements of the iterable to the collection. If
necessary and possible, the collection will be enlarged: if enlarging
the collection is not possible, then the runtime exception thrown.
Augmentation of the Collection.addAll(Collection) API method.
|
addAll | public static boolean addAll(Collection<? super T> cout, T[] ts)(Code) | | Adds all of the elements of the array to the collection. If
necessary and possible, the collection will be enlarged: if enlarging
the collection is not possible, then the runtime exception thrown.
Augmentation of the Collection.addAll(Collection) API method.
|
append | public static Collection<? super T> append(Collection<? super T> cout, Iterable<T> iter)(Code) | | Adds all of the elements of the iterable to the collection, and returns
the collection. If necessary and possible, the collection will be enlarged:
if enlarging the collection is not possible, then the runtime exception thrown.
Augmentation of the Collection.addAll(Collection) API method.
|
append | public static Collection<? super T> append(Collection<? super T> cout, T[] ts)(Code) | | Adds all of the elements of the array to the collection and returns the
collection. If necessary and possible, the collection will be enlarged:
if enlarging the collection is not possible, then the runtime exception
thrown. Augmentation of the Collection.addAll(Collection) API method.
|
findAll | public static Iterable<Iterator<? extends T>> findAll(T[] ts, UnaryFunctor<Iterator<? extends T>, ? extends Iterator<T>> fn)(Code) | | Returns iterators that point to the next instance in an iterable that
meets the condition described in the functor.
|
merge | public static Iterable<T> merge(Iterable<? extends T> i1, Iterable<? extends T> i2)(Code) | | Returns all elements of both iterables, always choosing the lesser of the
two current elements.
|
merge | public static Iterable<T> merge(T[] ts1, T[] ts2)(Code) | | Returns all elements of both arrays, always choosing the lesser of the
two current elements.
|
merge | public static Iterable<T> merge(Iterable<? extends T> i1, Iterable<? extends T> i2, Comparator<T> comp)(Code) | | Returns all elements of both iterables, always choosing the lesser of the
two current elements.
|
merge | public static Iterable<T> merge(T[] ts1, T[] ts2, Comparator<T> comp)(Code) | | Returns all elements of both arrays, always choosing the lesser of the
two current elements.
|
merge | public static Iterable<T> merge(Iterable<? extends T> i1, Iterable<? extends T> i2, BinaryFunctor<T, T, Boolean> fn)(Code) | | Returns all elements of both iterables, using the given predicate to
choose which element to return. If the predicate is true, choose the
current element of the first iterable, otherwise choose the current
element of the second iterable. When one is exhausted, returns elements
remaining in the other.
|
merge | public static Iterable<T> merge(T[] ts1, T[] ts2, BinaryFunctor<T, T, Boolean> fn)(Code) | | Returns all elements of both arrays, using the given predicate to
choose which element to return. If the predicate is true, choose the
current element of the first iterable, otherwise choose the current
element of the second iterable. When one is exhausted, returns elements
remaining in the other.
|
transform | public static Iterable<R> transform(Iterable<? extends T> i, UnaryFunctor<T, R> fn)(Code) | | Returns the results of applying the given functor to each element in turn.
|
transform | public static Iterable<R> transform(T[] ts, UnaryFunctor<T, R> fn)(Code) | | Returns the results of applying the given functor to each element in turn.
|
transform | public static Iterable<R> transform(T1[] ts1, T2[] ts2, BinaryFunctor<T1, T2, R> fn)(Code) | | Returns the results of applying the given functor to corresponding elements.
|
transform | public static Iterable<R> transform(Iterable<? extends T> i, BinaryFunctor<T, T, R> fn)(Code) | | Returns the results of applying the given functor to succesive pairs of elements.
|
transform | public static Iterable<R> transform(T[] ts, BinaryFunctor<T, T, R> fn)(Code) | | Returns the results of applying the given functor to succesive pairs of elements.
|
unique | public static Iterable<T> unique(Iterable<? extends T> i)(Code) | | Returns unduplicated results: will not return the same value twice in
succession. This version uses T.equals() to test for equality.
|
unique | public static Iterable<T> unique(T[] ts)(Code) | | Returns unduplicated results: will not return the same value twice in
succession. This version uses T.equals() to test for equality.
|
unique | public static Iterable<T> unique(Iterable<? extends T> i, BinaryFunctor<T, T, Boolean> eq)(Code) | | Returns unduplicated results: will not return the same value twice in
succession, as determined by the given predicate. The predicate should
return true when the adjacent items are the same.
|
unique | public static Iterable<T> unique(T[] ts, BinaryFunctor<T, T, Boolean> eq)(Code) | | Returns unduplicated results: will not return the same value twice in
succession, as determined by the given predicate. The predicate should
return true when the adjacent items are the same.
|
|
|