Why no return a collection when possible?
Jose
jgetino at telefonica.net
Sat Aug 4 13:16:19 PDT 2012
There are many cases in which the entry point of a pilpeline is a collection
and its size has not changed at the other end (no filters invoked).
In this case it would be good to get a Collection. Currently I doing this by
hand at the end of each pipeline using something like this:
public static <T> Collection<T> newCollection(final Iterable<T> iterable,
final int size) {
return new AbstractCollection<T>() {
public Iterator<T> iterator() {
return iterable.iterator();
}
public int size() {
return size;
}
};
}
The point is to preserve compatibility with the existing code, refractoring
collections to Iterables would be a major task.
More information about the lambda-dev
mailing list