Efficient way of mapping T to Map<X, Double>?

Michael Nascimento misterm at gmail.com
Wed Feb 13 16:39:35 PST 2013


Hi guys,

What is an efficient way of, given a Stream<T>, obtain a Map<X,
Double> (notice X is not the same type as T) given T is to be
converted to the Double type by calling a method that returns double
and is to be summed?

So far what I have is:

stream.collect(groupingReduce(d -> d.getX(), d -> d.getTotal(), Double::sum));

but this results in some boxing I wish I could avoid.

Regards,
Michael


More information about the lambda-dev mailing list