--- jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/08/13 15:52:33 1.52 +++ jsr166/src/jsr166e/ConcurrentHashMapV8.java 2012/08/13 19:52:33 1.57 @@ -712,7 +712,7 @@ public class ConcurrentHashMapV8 } /** - * Return the TreeNode (or null if not found) for the given key + * Returns the TreeNode (or null if not found) for the given key * starting at given root. */ @SuppressWarnings("unchecked") // suppress Comparable cast warning @@ -2327,7 +2327,7 @@ public class ConcurrentHashMapV8 } public final void remove() { - if (nextVal == null) + if (nextVal == null && last == null) advance(); Node e = last; if (e == null) @@ -2657,8 +2657,7 @@ public class ConcurrentHashMapV8 * * @param key key with which the specified value is to be associated * @param remappingFunction the function to compute a value - * @return the new value associated with - * the specified key, or null if none. + * @return the new value associated with the specified key, or null if none * @throws NullPointerException if the specified key or remappingFunction * is null * @throws IllegalStateException if the computation detectably @@ -2704,8 +2703,7 @@ public class ConcurrentHashMapV8 * * @param key key with which the specified value is to be associated * @param remappingFunction the function to compute a value - * @return the new value associated with - * the specified key, or null if none. + * @return the new value associated with the specified key, or null if none * @throws NullPointerException if the specified key or remappingFunction * is null * @throws IllegalStateException if the computation detectably @@ -2898,27 +2896,27 @@ public class ConcurrentHashMapV8 } /** - * Returns a partionable iterator of the keys in this map. + * Returns a partitionable iterator of the keys in this map. * - * @return a partionable iterator of the keys in this map + * @return a partitionable iterator of the keys in this map */ public Spliterator keySpliterator() { return new KeyIterator(this); } /** - * Returns a partionable iterator of the values in this map. + * Returns a partitionable iterator of the values in this map. * - * @return a partionable iterator of the values in this map + * @return a partitionable iterator of the values in this map */ public Spliterator valueSpliterator() { return new ValueIterator(this); } /** - * Returns a partionable iterator of the entries in this map. + * Returns a partitionable iterator of the entries in this map. * - * @return a partionable iterator of the entries in this map + * @return a partitionable iterator of the entries in this map */ public Spliterator> entrySpliterator() { return new EntryIterator(this); @@ -3518,7 +3516,7 @@ public class ConcurrentHashMapV8 /** * An extended view of a ConcurrentHashMap supporting bulk - * parallel operations. These operations are designed to be be + * parallel operations. These operations are designed to be * safely, and often sensibly, applied even with maps that are * being concurrently updated by other threads; for example, when * computing a snapshot summary of the values in a shared @@ -3636,7 +3634,7 @@ public class ConcurrentHashMapV8 * * @param action the action */ - public void forEach(BiAction action) { + public void forEach(BiAction action) { fjp.invoke(ForkJoinTasks.forEach (ConcurrentHashMapV8.this, action)); } @@ -3650,7 +3648,7 @@ public class ConcurrentHashMapV8 * which case the action is not applied). * @param action the action */ - public void forEach(BiFun transformer, + public void forEach(BiFun transformer, Action action) { fjp.invoke(ForkJoinTasks.forEach (ConcurrentHashMapV8.this, transformer, action)); @@ -3750,25 +3748,25 @@ public class ConcurrentHashMapV8 } /** - * Performs the given action for each key + * Performs the given action for each key. * * @param action the action */ - public void forEachKey(Action action) { + public void forEachKey(Action action) { fjp.invoke(ForkJoinTasks.forEachKey (ConcurrentHashMapV8.this, action)); } /** * Performs the given action for each non-null transformation - * of each key + * of each key. * * @param transformer a function returning the transformation * for an element, or null of there is no transformation (in * which case the action is not applied). * @param action the action */ - public void forEachKey(Fun transformer, + public void forEachKey(Fun transformer, Action action) { fjp.invoke(ForkJoinTasks.forEachKey (ConcurrentHashMapV8.this, transformer, action)); @@ -3880,24 +3878,24 @@ public class ConcurrentHashMapV8 } /** - * Performs the given action for each value + * Performs the given action for each value. * * @param action the action */ - public void forEachValue(Action action) { + public void forEachValue(Action action) { fjp.invoke(ForkJoinTasks.forEachValue (ConcurrentHashMapV8.this, action)); } /** * Performs the given action for each non-null transformation - * of each value + * of each value. * * @param transformer a function returning the transformation * for an element, or null of there is no transformation (in * which case the action is not applied). */ - public void forEachValue(Fun transformer, + public void forEachValue(Fun transformer, Action action) { fjp.invoke(ForkJoinTasks.forEachValue (ConcurrentHashMapV8.this, transformer, action)); @@ -4009,25 +4007,25 @@ public class ConcurrentHashMapV8 } /** - * Perform the given action for each entry + * Performs the given action for each entry. * * @param action the action */ - public void forEachEntry(Action> action) { + public void forEachEntry(Action> action) { fjp.invoke(ForkJoinTasks.forEachEntry (ConcurrentHashMapV8.this, action)); } /** - * Perform the given action for each non-null transformation - * of each entry + * Performs the given action for each non-null transformation + * of each entry. * * @param transformer a function returning the transformation * for an element, or null of there is no transformation (in * which case the action is not applied). * @param action the action */ - public void forEachEntry(Fun, ? extends U> transformer, + public void forEachEntry(Fun, ? extends U> transformer, Action action) { fjp.invoke(ForkJoinTasks.forEachEntry (ConcurrentHashMapV8.this, transformer, action)); @@ -4159,7 +4157,7 @@ public class ConcurrentHashMapV8 * @param action the action * @return the task */ - public static ForkJoinTask forEach + public static ForkJoinTask forEach (ConcurrentHashMapV8 map, BiAction action) { if (action == null) throw new NullPointerException(); @@ -4177,7 +4175,7 @@ public class ConcurrentHashMapV8 * @param action the action * @return the task */ - public static ForkJoinTask forEach + public static ForkJoinTask forEach (ConcurrentHashMapV8 map, BiFun transformer, Action action) { @@ -4304,13 +4302,13 @@ public class ConcurrentHashMapV8 /** * Returns a task that when invoked, performs the given action - * for each key + * for each key. * * @param map the map * @param action the action * @return the task */ - public static ForkJoinTask forEachKey + public static ForkJoinTask forEachKey (ConcurrentHashMapV8 map, Action action) { if (action == null) throw new NullPointerException(); @@ -4319,7 +4317,7 @@ public class ConcurrentHashMapV8 /** * Returns a task that when invoked, performs the given action - * for each non-null transformation of each key + * for each non-null transformation of each key. * * @param map the map * @param transformer a function returning the transformation @@ -4328,7 +4326,7 @@ public class ConcurrentHashMapV8 * @param action the action * @return the task */ - public static ForkJoinTask forEachKey + public static ForkJoinTask forEachKey (ConcurrentHashMapV8 map, Fun transformer, Action action) { @@ -4472,12 +4470,12 @@ public class ConcurrentHashMapV8 /** * Returns a task that when invoked, performs the given action - * for each value + * for each value. * * @param map the map * @param action the action */ - public static ForkJoinTask forEachValue + public static ForkJoinTask forEachValue (ConcurrentHashMapV8 map, Action action) { if (action == null) throw new NullPointerException(); @@ -4486,7 +4484,7 @@ public class ConcurrentHashMapV8 /** * Returns a task that when invoked, performs the given action - * for each non-null transformation of each value + * for each non-null transformation of each value. * * @param map the map * @param transformer a function returning the transformation @@ -4494,7 +4492,7 @@ public class ConcurrentHashMapV8 * which case the action is not applied). * @param action the action */ - public static ForkJoinTask forEachValue + public static ForkJoinTask forEachValue (ConcurrentHashMapV8 map, Fun transformer, Action action) { @@ -4640,12 +4638,12 @@ public class ConcurrentHashMapV8 /** * Returns a task that when invoked, perform the given action - * for each entry + * for each entry. * * @param map the map * @param action the action */ - public static ForkJoinTask forEachEntry + public static ForkJoinTask forEachEntry (ConcurrentHashMapV8 map, Action> action) { if (action == null) throw new NullPointerException(); @@ -4654,7 +4652,7 @@ public class ConcurrentHashMapV8 /** * Returns a task that when invoked, perform the given action - * for each non-null transformation of each entry + * for each non-null transformation of each entry. * * @param map the map * @param transformer a function returning the transformation @@ -4662,7 +4660,7 @@ public class ConcurrentHashMapV8 * which case the action is not applied). * @param action the action */ - public static ForkJoinTask forEachEntry + public static ForkJoinTask forEachEntry (ConcurrentHashMapV8 map, Fun, ? extends U> transformer, Action action) { @@ -4811,7 +4809,7 @@ public class ConcurrentHashMapV8 /** * Base for FJ tasks for bulk operations. This adds a variant of - * CountedCompleters and some split and merge bookeeping to + * CountedCompleters and some split and merge bookkeeping to * iterator functionality. The forEach and reduce methods are * similar to those illustrated in CountedCompleter documentation, * except that bottom-up reduction completions perform them within @@ -4842,7 +4840,7 @@ public class ConcurrentHashMapV8 // FJ methods /** - * Propagate completion. Note that all reduce actions + * Propagates completion. Note that all reduce actions * bypass this method to combine while completing. */ final void tryComplete() { @@ -4860,7 +4858,7 @@ public class ConcurrentHashMapV8 } /** - * Force root task to throw exception unless already complete. + * Forces root task to throw exception unless already complete. */ final void tryAbortComputation(Throwable ex) { for (BulkTask a = this;;) { @@ -4877,7 +4875,7 @@ public class ConcurrentHashMapV8 try { compute(); } - catch(Throwable ex) { + catch (Throwable ex) { tryAbortComputation(ex); } return false; @@ -4893,7 +4891,7 @@ public class ConcurrentHashMapV8 } /** - * Return approx exp2 of the number of times (minus one) to + * Returns approx exp2 of the number of times (minus one) to * split task by two before executing leaf action. This value * is faster to compute and more convenient to use as a guide * to splitting than is the depth, since it is used while @@ -4904,7 +4902,7 @@ public class ConcurrentHashMapV8 if (b < 0) { long n = map.counter.sum(); int sp = getPool().getParallelism() << 3; // slack of 8 - b = batch = (n <= 0L)? 0 : (n < (long)sp) ? (int)n : sp; + b = batch = (n <= 0L) ? 0 : (n < (long)sp) ? (int)n : sp; } return b; } @@ -4916,7 +4914,7 @@ public class ConcurrentHashMapV8 "Unexpected null function"; /** - * Return exportable snapshot entry + * Returns exportable snapshot entry. */ static AbstractMap.SimpleEntry entryFor(K k, V v) { return new AbstractMap.SimpleEntry(k, v);