A suggestion: Map.checkAndGet

Brian Goetz brian.goetz at oracle.com
Tue Oct 30 11:04:24 PDT 2012


> The pattern
> map.containsKey(k) ? map.get() : othervAlue
> (walks on tree twice)
> 
> repeats itself so many times, as in Mappers:

Note that this is an idiom that only works in the sequential case anyway.  In concurrent maps, this is a race.  




More information about the lambda-dev mailing list