ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentMap.java (file contents):
Revision 1.50 by jsr166, Sat Dec 7 17:26:50 2013 UTC vs.
Revision 1.51 by jsr166, Sat Dec 7 17:59:40 2013 UTC

# Line 71 | Line 71 | public interface ConcurrentMap<K,V> exte
71       *
72       * @implSpec The default implementation is equivalent to, for this
73       * {@code map}:
74 <     * <pre> {@code
74 >     *  <pre> {@code
75       * for (Map.Entry<K,V> entry : map.entrySet())
76       *   action.accept(entry.getKey(), entry.getValue());
77       * }</pre>
# Line 104 | Line 104 | public interface ConcurrentMap<K,V> exte
104      /**
105       * If the specified key is not already associated
106       * with a value, associates it with the given value.
107 <     * This is equivalent to
107 >     * This is equivalent to, for this {@code map}:
108       *  <pre> {@code
109       * if (map.containsKey(key))
110       *   return map.get(key);
# Line 136 | Line 136 | public interface ConcurrentMap<K,V> exte
136  
137      /**
138       * Removes the entry for a key only if currently mapped to a given value.
139 <     * This is equivalent to
139 >     * This is equivalent to, for this {@code map}:
140       *  <pre> {@code
141       * if (map.containsKey(key) && Objects.equals(map.get(key), value)) {
142       *   map.remove(key);
# Line 165 | Line 165 | public interface ConcurrentMap<K,V> exte
165  
166      /**
167       * Replaces the entry for a key only if currently mapped to a given value.
168 <     * This is equivalent to
168 >     * This is equivalent to, for this {@code map}:
169       *  <pre> {@code
170       * if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) {
171       *   map.put(key, newValue);
# Line 195 | Line 195 | public interface ConcurrentMap<K,V> exte
195  
196      /**
197       * Replaces the entry for a key only if currently mapped to some value.
198 <     * This is equivalent to
198 >     * This is equivalent to, for this {@code map}:
199       *  <pre> {@code
200 <     * if (map.containsKey(key)) {
200 >     * if (map.containsKey(key))
201       *   return map.put(key, value);
202 <     * } else
202 >     * else
203       *   return null;
204       * }</pre>
205       *
# Line 230 | Line 230 | public interface ConcurrentMap<K,V> exte
230       *
231       * @implSpec
232       * <p>The default implementation is equivalent to, for this {@code map}:
233 <     * <pre> {@code
233 >     *  <pre> {@code
234       * for (Map.Entry<K,V> entry : map.entrySet()) {
235       *   K k;
236       *   V v;
# Line 238 | Line 238 | public interface ConcurrentMap<K,V> exte
238       *     k = entry.getKey();
239       *     v = entry.getValue();
240       *   } while (!map.replace(k, v, function.apply(k, v)));
241 <     * }</pre>
241 >     * }}</pre>
242       *
243       * The default implementation may retry these steps when multiple
244       * threads attempt updates, and may call the function multiple
# Line 272 | Line 272 | public interface ConcurrentMap<K,V> exte
272       * {@code map}, then returning the current value or {@code null} if now
273       * absent:
274       *
275 <     * <pre> {@code
275 >     *  <pre> {@code
276       * if (map.get(key) == null) {
277 <     *     V newValue = mappingFunction.apply(key);
278 <     *     if (newValue != null)
279 <     *         return map.putIfAbsent(key, newValue);
280 <     * }
281 <     * }</pre>
277 >     *   V newValue = mappingFunction.apply(key);
278 >     *   if (newValue != null)
279 >     *     return map.putIfAbsent(key, newValue);
280 >     * }}</pre>
281       *
282       * The default implementation may retry these steps when multiple
283       * threads attempt updates, and may call the mapping function
# Line 305 | Line 304 | public interface ConcurrentMap<K,V> exte
304       * @implSpec
305       * The default implementation is equivalent to performing the following
306       * steps for this {@code map}, then returning the current value or
307 <     * {@code null} if now absent. :
307 >     * {@code null} if now absent:
308       *
309 <     * <pre> {@code
309 >     *  <pre> {@code
310       * if (map.get(key) != null) {
311 <     *     V oldValue = map.get(key);
312 <     *     V newValue = remappingFunction.apply(key, oldValue);
313 <     *     if (newValue != null)
314 <     *         map.replace(key, oldValue, newValue);
315 <     *     else
316 <     *         map.remove(key, oldValue);
317 <     * }
319 <     * }</pre>
311 >     *   V oldValue = map.get(key);
312 >     *   V newValue = remappingFunction.apply(key, oldValue);
313 >     *   if (newValue != null)
314 >     *     map.replace(key, oldValue, newValue);
315 >     *   else
316 >     *     map.remove(key, oldValue);
317 >     * }}</pre>
318       *
319       * The default implementation may retry these steps when multiple
320       * threads attempt updates, and may call the remapping function
# Line 351 | Line 349 | public interface ConcurrentMap<K,V> exte
349       * steps for this {@code map}, then returning the current value or
350       * {@code null} if absent:
351       *
352 <     * <pre> {@code
352 >     *  <pre> {@code
353       * V oldValue = map.get(key);
354       * V newValue = remappingFunction.apply(key, oldValue);
355       * if (oldValue != null ) {
356 <     *    if (newValue != null)
357 <     *       map.replace(key, oldValue, newValue);
358 <     *    else
359 <     *       map.remove(key, oldValue);
356 >     *   if (newValue != null)
357 >     *     map.replace(key, oldValue, newValue);
358 >     *   else
359 >     *     map.remove(key, oldValue);
360       * } else {
361 <     *    if (newValue != null)
362 <     *       map.putIfAbsent(key, newValue);
363 <     *    else
364 <     *       return null;
365 <     * }
368 <     * }</pre>
361 >     *   if (newValue != null)
362 >     *     map.putIfAbsent(key, newValue);
363 >     *   else
364 >     *     return null;
365 >     * }}</pre>
366       *
367       * The default implementation may retry these steps when multiple
368       * threads attempt updates, and may call the remapping function
# Line 422 | Line 419 | public interface ConcurrentMap<K,V> exte
419          }
420      }
421  
425
422      /**
423       * {@inheritDoc}
424       *
# Line 431 | Line 427 | public interface ConcurrentMap<K,V> exte
427       * steps for this {@code map}, then returning the current value or
428       * {@code null} if absent:
429       *
430 <     * <pre> {@code
430 >     *  <pre> {@code
431       * V oldValue = map.get(key);
432       * V newValue = (oldValue == null) ? value :
433 <     *              remappingFunction.apply(oldValue, value);
433 >     *     remappingFunction.apply(oldValue, value);
434       * if (newValue == null)
435 <     *     map.remove(key);
435 >     *   map.remove(key);
436       * else
437 <     *     map.put(key, newValue);
437 >     *   map.put(key, newValue);
438       * }</pre>
439       *
440       * The default implementation may retry these steps when multiple

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines