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.55 by dl, Wed Apr 29 11:42:13 2015 UTC vs.
Revision 1.56 by jsr166, Wed Apr 29 18:01:41 2015 UTC

# Line 40 | Line 40 | import java.util.function.Function;
40   * @param <K> the type of keys maintained by this map
41   * @param <V> the type of mapped values
42   */
43 < public interface ConcurrentMap<K, V> extends Map<K, V> {
43 > public interface ConcurrentMap<K,V> extends Map<K,V> {
44  
45      /**
46       * {@inheritDoc}
# Line 66 | Line 66 | public interface ConcurrentMap<K, V> ext
66       * @implSpec The default implementation is equivalent to, for this
67       * {@code map}:
68       * <pre> {@code
69 <     * for ((Map.Entry<K, V> entry : map.entrySet())
70 <     *     action.accept(entry.getKey(), entry.getValue());
69 >     * for (Map.Entry<K,V> entry : map.entrySet())
70 >     *   action.accept(entry.getKey(), entry.getValue());
71       * }</pre>
72       *
73       * @implNote The default implementation assumes that
# Line 81 | Line 81 | public interface ConcurrentMap<K, V> ext
81      @Override
82      default void forEach(BiConsumer<? super K, ? super V> action) {
83          Objects.requireNonNull(action);
84 <        for (Map.Entry<K, V> entry : entrySet()) {
84 >        for (Map.Entry<K,V> entry : entrySet()) {
85              K k;
86              V v;
87              try {
88                  k = entry.getKey();
89                  v = entry.getValue();
90 <            } catch(IllegalStateException ise) {
90 >            } catch (IllegalStateException ise) {
91                  // this usually means the entry is no longer in the map.
92                  continue;
93              }
# Line 229 | Line 229 | public interface ConcurrentMap<K, V> ext
229       * @implSpec
230       * <p>The default implementation is equivalent to, for this {@code map}:
231       * <pre> {@code
232 <     * for ((Map.Entry<K, V> entry : map.entrySet())
233 <     *     do {
234 <     *        K k = entry.getKey();
235 <     *        V v = entry.getValue();
236 <     *     } while(!replace(k, v, function.apply(k, v)));
232 >     * for (Map.Entry<K,V> entry : map.entrySet())
233 >     *   do {
234 >     *     K k = entry.getKey();
235 >     *     V v = entry.getValue();
236 >     *   } while (!replace(k, v, function.apply(k, v)));
237       * }</pre>
238       *
239       * The default implementation may retry these steps when multiple
# Line 255 | Line 255 | public interface ConcurrentMap<K, V> ext
255      default void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
256          Objects.requireNonNull(function);
257          forEach((k,v) -> {
258 <            while(!replace(k, v, function.apply(k, v))) {
258 >            while (!replace(k, v, function.apply(k, v))) {
259                  // v changed or k is gone
260                  if ( (v = get(k)) == null) {
261                      // k is no longer in the map.
# Line 343 | Line 343 | public interface ConcurrentMap<K, V> ext
343              BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
344          Objects.requireNonNull(remappingFunction);
345          V oldValue;
346 <        while((oldValue = get(key)) != null) {
346 >        while ((oldValue = get(key)) != null) {
347              V newValue = remappingFunction.apply(key, oldValue);
348              if (newValue != null) {
349                  if (replace(key, oldValue, newValue))
# Line 397 | Line 397 | public interface ConcurrentMap<K, V> ext
397              BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
398          Objects.requireNonNull(remappingFunction);
399          V oldValue = get(key);
400 <        for(;;) {
400 >        for (;;) {
401              V newValue = remappingFunction.apply(key, oldValue);
402              if (newValue == null) {
403                  // delete mapping

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines