Summary
-------
Specialized implementations of the `TreeMap` methods `putIfAbsent`, `computeIfAbsent`, `computeIfPresent`, `compute`, and `merge` are introduced.
Problem
-------
Default implementations of the `putIfAbsent`, `computeIfAbsent`, `computeIfPresent`, `compute`, and `merge` methods provided by `AbstractMap` delegate to the `get`, `put`, and `remove` methods, which may require traversing the tree twice. An optimized implementation can traverse the tree only once. This can provide a noticeable speedup, especially if the comparison method is expensive.
Solution
--------
Provide optimized implementations for these methods, similar to `HashMap`.
Specification
-------------
* As `TreeMap` now overrides the methods `putIfAbsent`, `computeIfAbsent`, `computeIfPresent`, `compute`, and `merge`, the `implSpec` section specified for the corresponding default methods in the `Map` interface is no longer relevant to `TreeMap` methods.
* The specification for the `TreeMap` method `computeIfAbsent` now additionally covers the concurrent update policy, as follows:
```
* <p>This method will, on a best-effort basis, throw a
* {@link ConcurrentModificationException} if it is detected that the
* mapping function modifies this map during computation.
*
* @throws ConcurrentModificationException if it is detected that the
* mapping function modified this map
```
* The specifications for the `TreeMap` methods `computeIfPresent`, `compute`, and `merge` now additionally cover the concurrent update policy, as follows:
```
* <p>This method will, on a best-effort basis, throw a
* {@link ConcurrentModificationException} if it is detected that the
* remapping function modifies this map during computation.
*
* @throws ConcurrentModificationException if it is detected that the
* remapping function modified this map
```
These additions are exactly copied from the specification of the corresponding `HashMap` methods.