Collectors.sumBy

Michael Nascimento misterm at gmail.com
Wed Jun 5 09:54:42 PDT 2013


Great, thanks Paul!

Regards,
Michael

On Wed, Jun 5, 2013 at 1:50 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> On Jun 5, 2013, at 6:31 PM, Michael Nascimento <misterm at gmail.com> wrote:
>
>> Hi folks,
>>
>> Is there any good reason I cannot see for Collectors.sumBy, giving one
>> could use mapToLong().sum() and avoid the costs of boxing?
>>
>
> Such Collector can be used with mapping, groupingBy and partitioningBy, e.g.
>
>  Stream<Foo> s = ...
>  Map<Foo, Long> m = s.collect(groupingBy(Function::identity, sumBy(this::mapFooToLong)));
>
> Paul.


More information about the lambda-dev mailing list