Stream operations -- current set
Andrey Breslav
andrey.breslav at jetbrains.com
Sun Oct 7 09:52:32 PDT 2012
> Intermediate / Lazy (Stateless)
> -------------------------------
>
> <U> MapStream<T, U> mapped(Mapper<? super T, ? extends U> mapper);
From my experience, the opposite one is much more useful:
<U> MapStream<U, T> mapped(Mapper<? super T, ? extends U> mapper);
Are we implying that in this case one should use groupBy() (create many pointless collections) and then map() to throw the collections away?
> Intermediate / Lazy (Stateful)
> ------------------------------
>
> Stream<T> uniqueElements();
>
> Stream<T> sorted(Comparator<? super T> comparator);
I don't see how these two operations fit in here: sort() has no chance of being lazy, AFAIU, and uniqueElements() needs misleadingly much state to be stored to be considered "reasonably lazy". If I am wrong, please correct me.
> Stream<T> cumulate(BinaryOperator<T> operator);
Could you explain what this does?
> T[] toArray(ArrayFactory<T>)
I support this and suggest to get rid of Object[] toArray()
> Don has suggested a multi-valued version of groupBy:
>
> <U> Map<U, Collection<T>> groupByMulti(FlatMapper<? super T, ? extends U> classifier);
>
> which is easy to implement and makes sense to me.
A philosophical question: what is our take on how minimal we want to keep the Stream API?
> There are a few others in the maybe-should-have list, including limit/skip/slice. But I'd like to nail down the details of the must-haves first.
I wouldn't call some of those "must-haves". So, the minimality question above is important.
--
Andrey Breslav
http://jetbrains.com
Develop with pleasure!
More information about the lambda-libs-spec-experts
mailing list