Returns a concurrent
Collector that accumulates elements into a
ConcurrentMap whose keys and values are the result of applying
the provided mapping functions to the input elements.
If the mapped keys contain duplicates (according to
Object#equals(Object)), an
IllegalStateException is
thrown when the collection operation is performed. If the mapped keys
may have duplicates, use
#toConcurrentMap(Function,Function,BinaryOperator) instead.
There are no guarantees on the type, mutability, or serializability
of the
ConcurrentMap returned.
API Note:
It is common for either the key or the value to be the input elements.
In this case, the utility method
java8.util.function.Functions#identity() may be helpful.
For example, the following produces a
ConcurrentMap mapping
students to their grade point average:
ConcurrentMap studentToGPA =
And the following produces a
ConcurrentMap mapping a
unique identifier to students:
ConcurrentMap studentIdToStudent =
This is a
Collector.Characteristics#CONCURRENT and
Collector.Characteristics#UNORDERED Collector.