--- jsr166/src/jsr166e/ConcurrentHashMapV8.java 2013/01/28 06:58:51 1.91 +++ jsr166/src/jsr166e/ConcurrentHashMapV8.java 2013/02/15 22:20:46 1.99 @@ -212,8 +212,8 @@ import java.io.Serializable; * @param the type of keys maintained by this map * @param the type of mapped values */ -public class ConcurrentHashMapV8 - implements ConcurrentMap, Serializable { +public class ConcurrentHashMapV8 + implements ConcurrentMap, Serializable { private static final long serialVersionUID = 7249069246763182397L; /** @@ -1977,7 +1977,7 @@ public class ConcurrentHashMapV8 } } - /* + /** * Moves and/or copies the nodes in each bin to new table. See * above for explanation. */ @@ -2279,7 +2279,7 @@ public class ConcurrentHashMapV8 */ @SuppressWarnings("serial") static class Traverser extends CountedCompleter { - final ConcurrentHashMapV8 map; + final ConcurrentHashMapV8 map; Node next; // the next entry to use Object nextKey; // cached key field of next V nextVal; // cached val field of next @@ -2291,7 +2291,7 @@ public class ConcurrentHashMapV8 int batch; // split control /** Creates iterator for all entries in the table. */ - Traverser(ConcurrentHashMapV8 map) { + Traverser(ConcurrentHashMapV8 map) { this.map = map; } @@ -2323,7 +2323,7 @@ public class ConcurrentHashMapV8 if (e != null) // advance past used/skipped node e = e.next; while (e == null) { // get to next non-null bin - ConcurrentHashMapV8 m; + ConcurrentHashMapV8 m; Node[] t; int b, i, n; Object ek; // must use locals if ((t = tab) != null) n = t.length; @@ -2376,7 +2376,7 @@ public class ConcurrentHashMapV8 * anyway. */ final int preSplit() { - ConcurrentHashMapV8 m; int b; Node[] t; ForkJoinPool pool; + ConcurrentHashMapV8 m; int b; Node[] t; ForkJoinPool pool; if ((b = batch) < 0 && (m = map) != null) { // force initialization if ((t = tab) == null && (t = tab = m.table) != null) baseLimit = baseSize = t.length; @@ -2687,7 +2687,7 @@ public class ConcurrentHashMapV8 * memoized result, as in: * *
 {@code
-     * map.computeIfAbsent(key, new Fun() {
+     * map.computeIfAbsent(key, new Fun() {
      *   public V map(K k) { return new Value(f(k)); }});}
* * @param key key with which the specified value is to be associated @@ -2894,8 +2894,7 @@ public class ConcurrentHashMapV8 * course only appropriate if it is acceptable to use the same * value for all additions from this view. * - * @param mappedValue the mapped value to use for any - * additions. + * @param mappedValue the mapped value to use for any additions * @return the set view * @throws NullPointerException if the mappedValue is null */ @@ -3069,8 +3068,8 @@ public class ConcurrentHashMapV8 @SuppressWarnings("serial") static final class KeyIterator extends Traverser implements Spliterator, Enumeration { - KeyIterator(ConcurrentHashMapV8 map) { super(map); } - KeyIterator(ConcurrentHashMapV8 map, Traverser it) { + KeyIterator(ConcurrentHashMapV8 map) { super(map); } + KeyIterator(ConcurrentHashMapV8 map, Traverser it) { super(map, it, -1); } public KeyIterator split() { @@ -3092,8 +3091,8 @@ public class ConcurrentHashMapV8 @SuppressWarnings("serial") static final class ValueIterator extends Traverser implements Spliterator, Enumeration { - ValueIterator(ConcurrentHashMapV8 map) { super(map); } - ValueIterator(ConcurrentHashMapV8 map, Traverser it) { + ValueIterator(ConcurrentHashMapV8 map) { super(map); } + ValueIterator(ConcurrentHashMapV8 map, Traverser it) { super(map, it, -1); } public ValueIterator split() { @@ -3116,8 +3115,8 @@ public class ConcurrentHashMapV8 @SuppressWarnings("serial") static final class EntryIterator extends Traverser implements Spliterator> { - EntryIterator(ConcurrentHashMapV8 map) { super(map); } - EntryIterator(ConcurrentHashMapV8 map, Traverser it) { + EntryIterator(ConcurrentHashMapV8 map) { super(map); } + EntryIterator(ConcurrentHashMapV8 map, Traverser it) { super(map, it, -1); } public EntryIterator split() { @@ -3139,11 +3138,11 @@ public class ConcurrentHashMapV8 /** * Exported Entry for iterators */ - static final class MapEntry implements Map.Entry { + static final class MapEntry implements Map.Entry { final K key; // non-null V val; // non-null - final ConcurrentHashMapV8 map; - MapEntry(K key, V val, ConcurrentHashMapV8 map) { + final ConcurrentHashMapV8 map; + MapEntry(K key, V val, ConcurrentHashMapV8 map) { this.key = key; this.val = val; this.map = map; @@ -3374,7 +3373,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) * @param action the action */ @SuppressWarnings("unchecked") public void forEachSequentially @@ -3418,7 +3417,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all (key, value) pairs @@ -3531,7 +3530,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) * @param action the action */ @SuppressWarnings("unchecked") public void forEachKeySequentially @@ -3596,7 +3595,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all keys @@ -3709,7 +3708,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) */ public void forEachValueSequentially (Fun transformer, @@ -3769,7 +3768,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all values @@ -3883,7 +3882,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) * @param action the action */ @SuppressWarnings("unchecked") public void forEachEntrySequentially @@ -3946,7 +3945,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all entries @@ -4058,7 +4057,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) * @param action the action */ public void forEachInParallel @@ -4093,7 +4092,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all (key, value) pairs @@ -4181,7 +4180,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) * @param action the action */ public void forEachKeyInParallel @@ -4230,7 +4229,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all keys @@ -4318,7 +4317,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) */ public void forEachValueInParallel (Fun transformer, @@ -4365,7 +4364,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all values @@ -4453,7 +4452,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case the action is not applied). + * which case the action is not applied) * @param action the action */ public void forEachEntryInParallel @@ -4501,7 +4500,7 @@ public class ConcurrentHashMapV8 * * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the result of accumulating the given transformation * of all entries @@ -4579,9 +4578,9 @@ public class ConcurrentHashMapV8 /** * Base class for views. */ - abstract static class CHMView { - final ConcurrentHashMapV8 map; - CHMView(ConcurrentHashMapV8 map) { this.map = map; } + abstract static class CHMView { + final ConcurrentHashMapV8 map; + CHMView(ConcurrentHashMapV8 map) { this.map = map; } /** * Returns the map backing this view. @@ -4716,14 +4715,14 @@ public class ConcurrentHashMapV8 * A view of a ConcurrentHashMapV8 as a {@link Set} of keys, in * which additions may optionally be enabled by mapping to a * common value. This class cannot be directly instantiated. See - * {@link #keySet}, {@link #keySet(Object)}, {@link #newKeySet()}, + * {@link #keySet()}, {@link #keySet(Object)}, {@link #newKeySet()}, * {@link #newKeySet(int)}. */ public static class KeySetView extends CHMView implements Set, java.io.Serializable { private static final long serialVersionUID = 7249069246763182397L; private final V value; - KeySetView(ConcurrentHashMapV8 map, V value) { // non-public + KeySetView(ConcurrentHashMapV8 map, V value) { // non-public super(map); this.value = value; } @@ -4733,7 +4732,7 @@ public class ConcurrentHashMapV8 * or {@code null} if additions are not supported. * * @return the default mapped value for additions, or {@code null} - * if not supported. + * if not supported */ public V getMappedValue() { return value; } @@ -4757,8 +4756,6 @@ public class ConcurrentHashMapV8 V v; if ((v = value) == null) throw new UnsupportedOperationException(); - if (e == null) - throw new NullPointerException(); return map.internalPut(e, v, true) == null; } public boolean addAll(Collection c) { @@ -4767,8 +4764,6 @@ public class ConcurrentHashMapV8 if ((v = value) == null) throw new UnsupportedOperationException(); for (K e : c) { - if (e == null) - throw new NullPointerException(); if (map.internalPut(e, v, true) == null) added = true; } @@ -4785,7 +4780,7 @@ public class ConcurrentHashMapV8 /** * A view of a ConcurrentHashMapV8 as a {@link Collection} of * values, in which additions are disabled. This class cannot be - * directly instantiated. See {@link #values}, + * directly instantiated. See {@link #values()}. * *

The view's {@code iterator} is a "weakly consistent" iterator * that will never throw {@link ConcurrentModificationException}, @@ -4795,7 +4790,7 @@ public class ConcurrentHashMapV8 */ public static final class ValuesView extends CHMView implements Collection { - ValuesView(ConcurrentHashMapV8 map) { super(map); } + ValuesView(ConcurrentHashMapV8 map) { super(map); } public final boolean contains(Object o) { return map.containsValue(o); } public final boolean remove(Object o) { if (o != null) { @@ -4835,11 +4830,11 @@ public class ConcurrentHashMapV8 /** * A view of a ConcurrentHashMapV8 as a {@link Set} of (key, value) * entries. This class cannot be directly instantiated. See - * {@link #entrySet}. + * {@link #entrySet()}. */ public static final class EntrySetView extends CHMView implements Set> { - EntrySetView(ConcurrentHashMapV8 map) { super(map); } + EntrySetView(ConcurrentHashMapV8 map) { super(map); } public final boolean contains(Object o) { Object k, v, r; Map.Entry e; return ((o instanceof Map.Entry) && @@ -4871,11 +4866,7 @@ public class ConcurrentHashMapV8 } public final boolean add(Entry e) { - K key = e.getKey(); - V value = e.getValue(); - if (key == null || value == null) - throw new NullPointerException(); - return map.internalPut(key, value, false) == null; + return map.internalPut(e.getKey(), e.getValue(), false) == null; } public final boolean addAll(Collection> c) { boolean added = false; @@ -4972,7 +4963,7 @@ public class ConcurrentHashMapV8 * @param map the map * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the task */ @@ -5139,7 +5130,7 @@ public class ConcurrentHashMapV8 * @param map the map * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the task */ @@ -5305,7 +5296,7 @@ public class ConcurrentHashMapV8 * @param map the map * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the task */ @@ -5471,7 +5462,7 @@ public class ConcurrentHashMapV8 * @param map the map * @param transformer a function returning the transformation * for an element, or null if there is no transformation (in - * which case it is not combined). + * which case it is not combined) * @param reducer a commutative associative combining function * @return the task */