Returns a
Collector implementing a "group by" operation on
input elements of type
T, grouping elements according to a
classification function, and returning the results in a
Map.
The classification function maps elements to some key type
K.
The collector produces a
Map> whose keys are the
values resulting from applying the classification function to the input
elements, and whose corresponding values are
Lists containing the
input elements which map to the associated key under the classification
function.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the
Map or
List objects returned.
Implementation Requirements:
This produces a result similar to:
groupingBy(classifier, toList())
Implementation Note:
The returned
Collector is not concurrent. For parallel stream
pipelines, the
combiner function operates by merging the keys
from one map into another, which can be an expensive operation. If
preservation of the order in which elements appear in the resulting
Mapcollector is not required, using
#groupingByConcurrent(Function)may offer better parallel performance.