Encounter order
Andrey Breslav
andrey.breslav at jetbrains.com
Fri Oct 26 05:55:08 PDT 2012
People don't expect ordering of the *keys*, and that's fine. What I
>>> was talking about was ordering of the values, since the Map returned
>>> is a Map<K, Collection<V>>.
>> Your reduceBy() looked like this:
>>
>> <U, W> Map<U, W> reduceBy(...)
>>
>> no collections anywhere. Was that a mistake?
>
> groupBy returns a Map<K,Collection<T>>.
>
> reduceBy returns a Map<K,W>, because instead of accumulating elements
> in a K bucket and sticking them in a collection, we reduce all the
> elements in the K bucket.
>
> For example:
>
> Map<Author, Document> longestDocByAuthor
> = docs.reduceBy(Document::getAuthor,
> (d1, d2) -> (d1.length() > d2.length() ? d1 : d2));
>
Yes. And my point was that thus no ordering considerations are
applicable to the result of reduceBy. Or am I missing something?
More information about the lambda-libs-spec-experts
mailing list