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.13 by dl, Sun Oct 19 13:38:34 2003 UTC vs.
Revision 1.14 by dl, Fri Nov 28 12:37:00 2003 UTC

# Line 9 | Line 9 | import java.util.Map;
9  
10   /**
11   * A {@link java.util.Map} providing additional atomic
12 < * <tt>putIfAbsent</tt> and <tt>remove</tt> methods.
12 > * <tt>putIfAbsent</tt>, <tt>remove</tt>, and <tt>replace</tt> methods.
13   * @since 1.5
14   * @author Doug Lea
15   * @param <K> the type of keys maintained by this map
# Line 52 | Line 52 | public interface ConcurrentMap<K, V> ext
52       * Remove entry for key only if currently mapped to given value.
53       * Acts as
54       * <pre>
55 <     *  if (map.get(key).equals(value)) {
55 >     *  if ((map.containsKey(key) && map.get(key).equals(value)) {
56       *     map.remove(key);
57       *     return true;
58       * } else return false;
# Line 67 | Line 67 | public interface ConcurrentMap<K, V> ext
67       */
68      boolean remove(Object key, Object value);
69  
70 +
71 +    /**
72 +     * Replace entry for key only if currently mapped to given value.
73 +     * Acts as
74 +     * <pre>
75 +     *  if ((map.containsKey(key) && map.get(key).equals(oldValue)) {
76 +     *     map.put(key, newValue);
77 +     *     return true;
78 +     * } else return false;
79 +     * </pre>
80 +     * except that the action is performed atomically.
81 +     * @param key key with which the specified value is associated.
82 +     * @param oldValue value expected to be associated with the specified key.
83 +     * @param newValue value to be associated with the specified key.
84 +     * @return true if the value was replaced
85 +     * @throws NullPointerException if this map does not permit <tt>null</tt>
86 +     *            keys or values, and the specified key or value is
87 +     *            <tt>null</tt>.
88 +     */
89 +    boolean replace(K key, V oldValue, V newValue);
90 +
91   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines