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.46 by dl, Sat Dec 7 12:20:12 2013 UTC vs.
Revision 1.47 by jsr166, Sat Dec 7 15:58:13 2013 UTC

# Line 40 | Line 40 | import java.util.function.Function;
40   *
41   * <p>This interface is a member of the
42   * <a href="{@docRoot}/../technotes/guides/collections/index.html">
43 < * Java Caollections Framework</a>.
43 > * Java Collections Framework</a>.
44   *
45   * @since 1.5
46   * @author Doug Lea
47   * @param <K> the type of keys maintained by this map
48   * @param <V> the type of mapped values
49   */
50 < public interface ConcurrentMap<K, V> extends Map<K, V> {
50 > public interface ConcurrentMap<K,V> extends Map<K,V> {
51  
52      /**
53       * {@inheritDoc}
# Line 72 | Line 72 | public interface ConcurrentMap<K, V> ext
72       * @implSpec The default implementation is equivalent to, for this
73       * {@code map}:
74       * <pre> {@code
75 <     * for ((Map.Entry<K, V> entry : map.entrySet())
75 >     * for ((Map.Entry<K,V> entry : map.entrySet())
76       *     action.accept(entry.getKey(), entry.getValue());
77       * }</pre>
78       *
# Line 87 | Line 87 | public interface ConcurrentMap<K, V> ext
87      @Override
88      default void forEach(BiConsumer<? super K, ? super V> action) {
89          Objects.requireNonNull(action);
90 <        for (Map.Entry<K, V> entry : entrySet()) {
90 >        for (Map.Entry<K,V> entry : entrySet()) {
91              K k;
92              V v;
93              try {
94                  k = entry.getKey();
95                  v = entry.getValue();
96 <            } catch(IllegalStateException ise) {
96 >            } catch (IllegalStateException ise) {
97                  // this usually means the entry is no longer in the map.
98                  continue;
99              }
# Line 132 | Line 132 | public interface ConcurrentMap<K, V> ext
132       * @throws IllegalArgumentException if some property of the specified key
133       *         or value prevents it from being stored in this map
134       */
135 <     V putIfAbsent(K key, V value);
135 >    V putIfAbsent(K key, V value);
136  
137      /**
138       * Removes the entry for a key only if currently mapped to a given value.
# Line 231 | Line 231 | public interface ConcurrentMap<K, V> ext
231       * @implSpec
232       * <p>The default implementation is equivalent to, for this {@code map}:
233       * <pre> {@code
234 <     * for ((Map.Entry<K, V> entry : map.entrySet())
234 >     * for ((Map.Entry<K,V> entry : map.entrySet())
235       *     do {
236       *        K k = entry.getKey();
237       *        V v = entry.getValue();
238 <     *     } while(!replace(k, v, function.apply(k, v)));
238 >     *     } while (!replace(k, v, function.apply(k, v)));
239       * }</pre>
240       *
241       * The default implementation may retry these steps when multiple
# Line 252 | Line 252 | public interface ConcurrentMap<K, V> ext
252      default void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
253          Objects.requireNonNull(function);
254          forEach((k,v) -> {
255 <            while(!replace(k, v, function.apply(k, v))) {
255 >            while (!replace(k, v, function.apply(k, v))) {
256                  // v changed or k is gone
257                  if ( (v = get(k)) == null) {
258                      // k is no longer in the map.
# Line 330 | Line 330 | public interface ConcurrentMap<K, V> ext
330              BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
331          Objects.requireNonNull(remappingFunction);
332          V oldValue;
333 <        while((oldValue = get(key)) != null) {
333 >        while ((oldValue = get(key)) != null) {
334              V newValue = remappingFunction.apply(key, oldValue);
335              if (newValue != null) {
336                  if (replace(key, oldValue, newValue))
# Line 379 | Line 379 | public interface ConcurrentMap<K, V> ext
379              BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
380          Objects.requireNonNull(remappingFunction);
381          V oldValue = get(key);
382 <        for(;;) {
382 >        for (;;) {
383              V newValue = remappingFunction.apply(key, oldValue);
384              if (newValue == null) {
385                  // delete mapping

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines