groupingByConcurrent javadoc shows an example use that does not require a map factory
Brian Goetz
brian.goetz at oracle.com
Mon Jun 17 17:22:53 PDT 2013
Ah, OK. It should be ConcurrentSkipListMap (the concurrent Map impl
with sorted keys.)
On 6/17/2013 8:11 PM, Arul Dhesiaseelan wrote:
> Ok, this example fails to compile in build 94 with incompatible types
> error, since TreeMap is not a ConcurrentMap, so this example still needs
> correction, no?
>
> java: incompatible types: Cannot instantiate inference variables T
> because of an inference loop
>
>
> On Mon, Jun 17, 2013 at 1:21 PM, Brian Goetz <brian.goetz at oracle.com
> <mailto:brian.goetz at oracle.com>> wrote:
>
> No, the default factory is HashMap::new. This asks for a TreeMap,
> which has the additional property of having a sorted encounter order
> for keys.
>
>
> On 6/17/2013 7:13 PM, Arul Dhesiaseelan wrote:
>
> Looks like this example in Collectors javadoc needs to be
> corrected for
> groupingByConcurrent that does not take a map factory?
>
> ConcurrentMap<City, Set<String>> namesByCity
> =
> people.stream().collect(__groupingByConcurrent(Person::__getCity, TreeMap::new,
>
> mapping(Person::getLastName, toSet())));
>
> map factory should not be included in this example, as it uses
> the default
> factory.
>
> - Arul
>
>
More information about the lambda-dev
mailing list