eclipse / eclipse-collections

Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.
http://www.eclipse.org/collections
2.42k stars 604 forks source link

Override Map.merge() default method for correctness and efficiency. Partially addresses #500 #1542

Closed motlin closed 7 months ago

mohrezaei commented 8 months ago

Just thinking this over:

mohrezaei commented 7 months ago

additional things to do from the javadoc:

1) If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged. 2) In particular, all implementations of subinterface ConcurrentMap must document whether the remapping function is applied once atomically only if the value is not present.

for (2), we have to document that all these are possible:

Also I think the javadoc language for (2) is broken. "applied once atomically only if the value is not present. " is not sensible: if it's not present, it shouldn't have been applied, no?

for (1), we can't leave the map in an intermediate state. I don't see any such case, but a test or two would be good.