mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8247402: Documentation for Map::compute contains confusing implementation requirements
Reviewed-by: prappo, martin
This commit is contained in:
parent
d4282b0cfc
commit
37dc675cd0
1 changed files with 6 additions and 12 deletions
|
@ -1109,23 +1109,17 @@ public interface Map<K, V> {
|
|||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to performing the following
|
||||
* steps for this {@code map}, then returning the current value or
|
||||
* {@code null} if absent:
|
||||
* steps for this {@code map}:
|
||||
*
|
||||
* <pre> {@code
|
||||
* V oldValue = map.get(key);
|
||||
* V newValue = remappingFunction.apply(key, oldValue);
|
||||
* if (oldValue != null) {
|
||||
* if (newValue != null)
|
||||
* map.put(key, newValue);
|
||||
* else
|
||||
* map.remove(key);
|
||||
* } else {
|
||||
* if (newValue != null)
|
||||
* map.put(key, newValue);
|
||||
* else
|
||||
* return null;
|
||||
* if (newValue != null) {
|
||||
* map.put(key, newValue);
|
||||
* } else if (oldValue != null || map.containsKey(key)) {
|
||||
* map.remove(key);
|
||||
* }
|
||||
* return newValue;
|
||||
* }</pre>
|
||||
*
|
||||
* <p>The default implementation makes no guarantees about detecting if the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue