ConcurrentHashMap/ConcurrentMap/Map.compute (original) (raw)

Doug Lea dl at cs.oswego.edu
Thu Dec 6 04:29:16 PST 2012


On 12/05/12 16:50, Doug Lea wrote:

On 12/05/12 16:31, Brian Goetz wrote:

Bikeshed: The name "replaceIfPresent" seems nicer than "computeIfPresent" and fits in with existing replace naming. OK; none of the names of it are beautiful, but either the analog-of-computeIfAbsent of of replace fine.

(This may be the most mangled sentence I have ever sent in an e-mail! The result of mis-pasting the javadocs with cursor in the middle of it and then over-undo'ing.)

I'm back to agreeing with myself and Joe. "replaceIfPresent" is redundant-sounding. Better to keep the symmetry with computeIfAbsent.

Changing replace(K,null) would be a CHM spec change (now throws NPE) but an innocuous one .

Actually, it would be a ConcurrentMap spec change, which is definitely crossing the line. It will take some further thought to see if there is a spec/wording that is both safe and useful.

-Doug



More information about the lambda-libs-spec-experts mailing list