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.20 by dl, Thu Jun 24 23:55:02 2004 UTC vs.
Revision 1.21 by jsr166, Tue Apr 26 01:43:01 2005 UTC

# Line 14 | Line 14 | import java.util.Map;
14   * <p>This interface is a member of the
15   * <a href="{@docRoot}/../guide/collections/index.html">
16   * Java Collections Framework</a>.
17 < *  
17 > *
18   * @since 1.5
19   * @author Doug Lea
20   * @param <K> the type of keys maintained by this map
21 < * @param <V> the type of mapped values
21 > * @param <V> the type of mapped values
22   */
23   public interface ConcurrentMap<K, V> extends Map<K, V> {
24      /**
# Line 26 | Line 26 | public interface ConcurrentMap<K, V> ext
26       * with a value, associate it with the given value.
27       * This is equivalent to
28       * <pre>
29 <     *   if (!map.containsKey(key))
30 <     *      return map.put(key, value);
29 >     *   if (!map.containsKey(key))
30 >     *       return map.put(key, value);
31       *   else
32 <     *      return map.get(key);
32 >     *       return map.get(key);
33       * </pre>
34 <     * Except that the action is performed atomically.
34 >     * except that the action is performed atomically.
35 >     *
36       * @param key key with which the specified value is to be associated.
37       * @param value value to be associated with the specified key.
38       * @return previous value associated with specified key, or <tt>null</tt>
# Line 39 | Line 40 | public interface ConcurrentMap<K, V> ext
40       *         also indicate that the map previously associated <tt>null</tt>
41       *         with the specified key, if the implementation supports
42       *         <tt>null</tt> values.
42     *
43       * @throws UnsupportedOperationException if the <tt>put</tt> operation is
44 <     *            not supported by this map.
44 >     *         not supported by this map.
45       * @throws ClassCastException if the class of the specified key or value
46 <     *            prevents it from being stored in this map.
46 >     *         prevents it from being stored in this map.
47       * @throws IllegalArgumentException if some aspect of this key or value
48 <     *            prevents it from being stored in this map.
48 >     *         prevents it from being stored in this map.
49       * @throws NullPointerException if this map does not permit <tt>null</tt>
50 <     *            keys or values, and the specified key or value is
51 <     *            <tt>null</tt>.
50 >     *         keys or values, and the specified key or value is <tt>null</tt>.
51       *
52       */
53      V putIfAbsent(K key, V value);
54  
55      /**
56 <     * Remove entry for key only if currently mapped to given value.
57 <     * Acts as
58 <     * <pre>
59 <     *  if ((map.containsKey(key) && map.get(key).equals(value)) {
60 <     *     map.remove(key);
61 <     *     return true;
62 <     * } else return false;
56 >     * Removes the entry for a key only if currently mapped to a given value.
57 >     * This is equivalent to
58 >     * <pre>
59 >     *   if (map.containsKey(key) && map.get(key).equals(value)) {
60 >     *       map.remove(key);
61 >     *       return true;
62 >     *   } else return false;
63       * </pre>
64       * except that the action is performed atomically.
65 +     *
66       * @param key key with which the specified value is associated.
67       * @param value value associated with the specified key.
68       * @return true if the value was removed, false otherwise
69       * @throws UnsupportedOperationException if the <tt>remove</tt> operation is
70 <     *            not supported by this map.
70 >     *         not supported by this map.
71       * @throws NullPointerException if this map does not permit <tt>null</tt>
72 <     *            keys or values, and the specified key or value is
73 <     *            <tt>null</tt>.
72 >     *         keys or values, and the specified key or value is <tt>null</tt>.
73       */
74      boolean remove(Object key, Object value);
75  
77
76      /**
77 <     * Replace entry for key only if currently mapped to given value.
78 <     * Acts as
79 <     * <pre>
80 <     *  if ((map.containsKey(key) && map.get(key).equals(oldValue)) {
81 <     *     map.put(key, newValue);
82 <     *     return true;
83 <     * } else return false;
77 >     * Replaces the entry for a key only if currently mapped to a given value.
78 >     * This is equivalent to
79 >     * <pre>
80 >     *   if (map.containsKey(key) && map.get(key).equals(oldValue)) {
81 >     *       map.put(key, newValue);
82 >     *       return true;
83 >     *   } else return false;
84       * </pre>
85       * except that the action is performed atomically.
86 +     *
87       * @param key key with which the specified value is associated.
88       * @param oldValue value expected to be associated with the specified key.
89       * @param newValue value to be associated with the specified key.
90       * @return true if the value was replaced
91       * @throws UnsupportedOperationException if the <tt>put</tt> operation is
92 <     *            not supported by this map.
92 >     *         not supported by this map.
93       * @throws NullPointerException if this map does not permit <tt>null</tt>
94 <     *            keys or values, and the specified key or value is
96 <     *            <tt>null</tt>.
94 >     *         keys or values, and the specified key or value is <tt>null</tt>.
95       */
96      boolean replace(K key, V oldValue, V newValue);
97  
98      /**
99 <     * Replace entry for key only if currently mapped to some value.
100 <     * Acts as
101 <     * <pre>
102 <     *  if ((map.containsKey(key)) {
103 <     *     return map.put(key, value);
104 <     * } else return null;
99 >     * Replaces the entry for a key only if currently mapped to some value.
100 >     * This is equivalent to
101 >     * <pre>
102 >     *   if (map.containsKey(key)) {
103 >     *       return map.put(key, value);
104 >     *   } else return null;
105       * </pre>
106       * except that the action is performed atomically.
107 +     *
108       * @param key key with which the specified value is associated.
109       * @param value value to be associated with the specified key.
110       * @return previous value associated with specified key, or <tt>null</tt>
# Line 114 | Line 113 | public interface ConcurrentMap<K, V> ext
113       *         with the specified key, if the implementation supports
114       *         <tt>null</tt> values.
115       * @throws UnsupportedOperationException if the <tt>put</tt> operation is
116 <     *            not supported by this map.
116 >     *         not supported by this map.
117       * @throws NullPointerException if this map does not permit <tt>null</tt>
118 <     *            keys or values, and the specified key or value is
120 <     *            <tt>null</tt>.
118 >     *         keys or values, and the specified key or value is <tt>null</tt>.
119       */
120      V replace(K key, V value);
121  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines