5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166e; |
8 |
– |
import jsr166e.LongAdder; |
9 |
– |
import jsr166e.ForkJoinPool; |
10 |
– |
import jsr166e.ForkJoinTask; |
8 |
|
|
9 |
|
import java.util.Comparator; |
10 |
|
import java.util.Arrays; |
82 |
|
* {@code hashCode()} is a sure way to slow down performance of any |
83 |
|
* hash table. |
84 |
|
* |
85 |
+ |
* <p> A {@link Set} projection of a ConcurrentHashMapV8 may be created |
86 |
+ |
* (using {@link #newKeySet()} or {@link #newKeySet(int)}), or viewed |
87 |
+ |
* (using {@link #keySet(Object)} when only keys are of interest, and the |
88 |
+ |
* mapped values are (perhaps transiently) not used or all take the |
89 |
+ |
* same mapping value. |
90 |
+ |
* |
91 |
+ |
* <p> A ConcurrentHashMapV8 can be used as scalable frequency map (a |
92 |
+ |
* form of histogram or multiset) by using {@link LongAdder} values |
93 |
+ |
* and initializing via {@link #computeIfAbsent}. For example, to add |
94 |
+ |
* a count to a {@code ConcurrentHashMapV8<String,LongAdder> freqs}, you |
95 |
+ |
* can use {@code freqs.computeIfAbsent(k -> new |
96 |
+ |
* LongAdder()).increment();} |
97 |
+ |
* |
98 |
|
* <p>This class and its views and iterators implement all of the |
99 |
|
* <em>optional</em> methods of the {@link Map} and {@link Iterator} |
100 |
|
* interfaces. |
102 |
|
* <p> Like {@link Hashtable} but unlike {@link HashMap}, this class |
103 |
|
* does <em>not</em> allow {@code null} to be used as a key or value. |
104 |
|
* |
105 |
+ |
* <p>ConcurrentHashMapV8s support parallel operations using the {@link |
106 |
+ |
* ForkJoinPool#commonPool}. (Task that may be used in other contexts |
107 |
+ |
* are available in class {@link ForkJoinTasks}). These operations are |
108 |
+ |
* designed to be safely, and often sensibly, applied even with maps |
109 |
+ |
* that are being concurrently updated by other threads; for example, |
110 |
+ |
* when computing a snapshot summary of the values in a shared |
111 |
+ |
* registry. There are three kinds of operation, each with four |
112 |
+ |
* forms, accepting functions with Keys, Values, Entries, and (Key, |
113 |
+ |
* Value) arguments and/or return values. Because the elements of a |
114 |
+ |
* ConcurrentHashMapV8 are not ordered in any particular way, and may be |
115 |
+ |
* processed in different orders in different parallel executions, the |
116 |
+ |
* correctness of supplied functions should not depend on any |
117 |
+ |
* ordering, or on any other objects or values that may transiently |
118 |
+ |
* change while computation is in progress; and except for forEach |
119 |
+ |
* actions, should ideally be side-effect-free. |
120 |
+ |
* |
121 |
+ |
* <ul> |
122 |
+ |
* <li> forEach: Perform a given action on each element. |
123 |
+ |
* A variant form applies a given transformation on each element |
124 |
+ |
* before performing the action.</li> |
125 |
+ |
* |
126 |
+ |
* <li> search: Return the first available non-null result of |
127 |
+ |
* applying a given function on each element; skipping further |
128 |
+ |
* search when a result is found.</li> |
129 |
+ |
* |
130 |
+ |
* <li> reduce: Accumulate each element. The supplied reduction |
131 |
+ |
* function cannot rely on ordering (more formally, it should be |
132 |
+ |
* both associative and commutative). There are five variants: |
133 |
+ |
* |
134 |
+ |
* <ul> |
135 |
+ |
* |
136 |
+ |
* <li> Plain reductions. (There is not a form of this method for |
137 |
+ |
* (key, value) function arguments since there is no corresponding |
138 |
+ |
* return type.)</li> |
139 |
+ |
* |
140 |
+ |
* <li> Mapped reductions that accumulate the results of a given |
141 |
+ |
* function applied to each element.</li> |
142 |
+ |
* |
143 |
+ |
* <li> Reductions to scalar doubles, longs, and ints, using a |
144 |
+ |
* given basis value.</li> |
145 |
+ |
* |
146 |
+ |
* </li> |
147 |
+ |
* </ul> |
148 |
+ |
* </ul> |
149 |
+ |
* |
150 |
+ |
* <p>The concurrency properties of bulk operations follow |
151 |
+ |
* from those of ConcurrentHashMapV8: Any non-null result returned |
152 |
+ |
* from {@code get(key)} and related access methods bears a |
153 |
+ |
* happens-before relation with the associated insertion or |
154 |
+ |
* update. The result of any bulk operation reflects the |
155 |
+ |
* composition of these per-element relations (but is not |
156 |
+ |
* necessarily atomic with respect to the map as a whole unless it |
157 |
+ |
* is somehow known to be quiescent). Conversely, because keys |
158 |
+ |
* and values in the map are never null, null serves as a reliable |
159 |
+ |
* atomic indicator of the current lack of any result. To |
160 |
+ |
* maintain this property, null serves as an implicit basis for |
161 |
+ |
* all non-scalar reduction operations. For the double, long, and |
162 |
+ |
* int versions, the basis should be one that, when combined with |
163 |
+ |
* any other value, returns that other value (more formally, it |
164 |
+ |
* should be the identity element for the reduction). Most common |
165 |
+ |
* reductions have these properties; for example, computing a sum |
166 |
+ |
* with basis 0 or a minimum with basis MAX_VALUE. |
167 |
+ |
* |
168 |
+ |
* <p>Search and transformation functions provided as arguments |
169 |
+ |
* should similarly return null to indicate the lack of any result |
170 |
+ |
* (in which case it is not used). In the case of mapped |
171 |
+ |
* reductions, this also enables transformations to serve as |
172 |
+ |
* filters, returning null (or, in the case of primitive |
173 |
+ |
* specializations, the identity basis) if the element should not |
174 |
+ |
* be combined. You can create compound transformations and |
175 |
+ |
* filterings by composing them yourself under this "null means |
176 |
+ |
* there is nothing there now" rule before using them in search or |
177 |
+ |
* reduce operations. |
178 |
+ |
* |
179 |
+ |
* <p>Methods accepting and/or returning Entry arguments maintain |
180 |
+ |
* key-value associations. They may be useful for example when |
181 |
+ |
* finding the key for the greatest value. Note that "plain" Entry |
182 |
+ |
* arguments can be supplied using {@code new |
183 |
+ |
* AbstractMap.SimpleEntry(k,v)}. |
184 |
+ |
* |
185 |
+ |
* <p> Bulk operations may complete abruptly, throwing an |
186 |
+ |
* exception encountered in the application of a supplied |
187 |
+ |
* function. Bear in mind when handling such exceptions that other |
188 |
+ |
* concurrently executing functions could also have thrown |
189 |
+ |
* exceptions, or would have done so if the first exception had |
190 |
+ |
* not occurred. |
191 |
+ |
* |
192 |
+ |
* <p>Parallel speedups for bulk operations compared to sequential |
193 |
+ |
* processing are common but not guaranteed. Operations involving |
194 |
+ |
* brief functions on small maps may execute more slowly than |
195 |
+ |
* sequential loops if the underlying work to parallelize the |
196 |
+ |
* computation is more expensive than the computation |
197 |
+ |
* itself. Similarly, parallelization may not lead to much actual |
198 |
+ |
* parallelism if all processors are busy performing unrelated tasks. |
199 |
+ |
* |
200 |
+ |
* <p> All arguments to all task methods must be non-null. |
201 |
+ |
* |
202 |
+ |
* <p><em>jsr166e note: During transition, this class |
203 |
+ |
* uses nested functional interfaces with different names but the |
204 |
+ |
* same forms as those expected for JDK8.<em> |
205 |
+ |
* |
206 |
|
* <p>This class is a member of the |
207 |
|
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> |
208 |
|
* Java Collections Framework</a>. |
209 |
|
* |
99 |
– |
* <p><em>jsr166e note: This class is a candidate replacement for |
100 |
– |
* java.util.concurrent.ConcurrentHashMap. During transition, this |
101 |
– |
* class declares and uses nested functional interfaces with different |
102 |
– |
* names but the same forms as those expected for JDK8.<em> |
103 |
– |
* |
210 |
|
* @since 1.5 |
211 |
|
* @author Doug Lea |
212 |
|
* @param <K> the type of keys maintained by this map |
285 |
|
Spliterator<T> split(); |
286 |
|
} |
287 |
|
|
288 |
+ |
/** |
289 |
+ |
* A view of a ConcurrentHashMapV8 as a {@link Set} of keys, in |
290 |
+ |
* which additions may optionally be enabled by mapping to a |
291 |
+ |
* common value. This class cannot be directly instantiated. See |
292 |
+ |
* {@link #keySet}, {@link #keySet(Object)}, {@link #newKeySet()}, |
293 |
+ |
* {@link #newKeySet(int)}. |
294 |
+ |
* |
295 |
+ |
* <p>The view's {@code iterator} is a "weakly consistent" iterator |
296 |
+ |
* that will never throw {@link ConcurrentModificationException}, |
297 |
+ |
* and guarantees to traverse elements as they existed upon |
298 |
+ |
* construction of the iterator, and may (but is not guaranteed to) |
299 |
+ |
* reflect any modifications subsequent to construction. |
300 |
+ |
*/ |
301 |
+ |
public static class KeySetView<K,V> extends CHMView<K,V> implements Set<K>, java.io.Serializable { |
302 |
+ |
private static final long serialVersionUID = 7249069246763182397L; |
303 |
+ |
private final V value; |
304 |
+ |
KeySetView(ConcurrentHashMapV8<K, V> map, V value) { // non-public |
305 |
+ |
super(map); |
306 |
+ |
this.value = value; |
307 |
+ |
} |
308 |
+ |
|
309 |
+ |
/** |
310 |
+ |
* Returns the map backing this view. |
311 |
+ |
* |
312 |
+ |
* @return the map backing this view |
313 |
+ |
*/ |
314 |
+ |
public ConcurrentHashMapV8<K,V> getMap() { return map; } |
315 |
+ |
|
316 |
+ |
/** |
317 |
+ |
* Returns the default mapped value for additions, |
318 |
+ |
* or {@code null} if additions are not supported. |
319 |
+ |
* |
320 |
+ |
* @return the default mapped value for additions, or {@code null} |
321 |
+ |
* if not supported. |
322 |
+ |
*/ |
323 |
+ |
public V getMappedValue() { return value; } |
324 |
+ |
|
325 |
+ |
// implement Set API |
326 |
+ |
|
327 |
+ |
public boolean contains(Object o) { return map.containsKey(o); } |
328 |
+ |
public boolean remove(Object o) { return map.remove(o) != null; } |
329 |
+ |
public Iterator<K> iterator() { return new KeyIterator<K,V>(map); } |
330 |
+ |
public boolean add(K e) { |
331 |
+ |
V v; |
332 |
+ |
if ((v = value) == null) |
333 |
+ |
throw new UnsupportedOperationException(); |
334 |
+ |
if (e == null) |
335 |
+ |
throw new NullPointerException(); |
336 |
+ |
return map.internalPutIfAbsent(e, v) == null; |
337 |
+ |
} |
338 |
+ |
public boolean addAll(Collection<? extends K> c) { |
339 |
+ |
boolean added = false; |
340 |
+ |
V v; |
341 |
+ |
if ((v = value) == null) |
342 |
+ |
throw new UnsupportedOperationException(); |
343 |
+ |
for (K e : c) { |
344 |
+ |
if (e == null) |
345 |
+ |
throw new NullPointerException(); |
346 |
+ |
if (map.internalPutIfAbsent(e, v) == null) |
347 |
+ |
added = true; |
348 |
+ |
} |
349 |
+ |
return added; |
350 |
+ |
} |
351 |
+ |
public boolean equals(Object o) { |
352 |
+ |
Set<?> c; |
353 |
+ |
return ((o instanceof Set) && |
354 |
+ |
((c = (Set<?>)o) == this || |
355 |
+ |
(containsAll(c) && c.containsAll(this)))); |
356 |
+ |
} |
357 |
+ |
} |
358 |
+ |
|
359 |
|
/* |
360 |
|
* Overview: |
361 |
|
* |
638 |
|
private transient volatile int sizeCtl; |
639 |
|
|
640 |
|
// views |
641 |
< |
private transient KeySet<K,V> keySet; |
641 |
> |
private transient KeySetView<K,V> keySet; |
642 |
|
private transient Values<K,V> values; |
643 |
|
private transient EntrySet<K,V> entrySet; |
644 |
|
|
2420 |
|
* change (including to null, indicating deletion), field nextVal |
2421 |
|
* might not be accurate at point of use, but still maintains the |
2422 |
|
* weak consistency property of holding a value that was once |
2423 |
< |
* valid. |
2423 |
> |
* valid. To support iterator.remove, the nextKey field is not |
2424 |
> |
* updated (nulled out) when the iterator cannot advance. |
2425 |
|
* |
2426 |
|
* Internal traversals directly access these fields, as in: |
2427 |
|
* {@code while (it.advance() != null) { process(it.nextKey); }} |
2458 |
|
@SuppressWarnings("serial") static class Traverser<K,V,R> extends ForkJoinTask<R> { |
2459 |
|
final ConcurrentHashMapV8<K, V> map; |
2460 |
|
Node next; // the next entry to use |
2283 |
– |
Node last; // the last entry used |
2461 |
|
Object nextKey; // cached key field of next |
2462 |
|
Object nextVal; // cached val field of next |
2463 |
|
Node[] tab; // current table; updated if resized |
2490 |
|
* See above for explanation. |
2491 |
|
*/ |
2492 |
|
final Object advance() { |
2493 |
< |
Node e = last = next; |
2493 |
> |
Node e = next; |
2494 |
|
Object ev = null; |
2495 |
|
outer: do { |
2496 |
|
if (e != null) // advance past used/skipped node |
2524 |
|
} |
2525 |
|
|
2526 |
|
public final void remove() { |
2527 |
< |
if (nextVal == null && last == null) |
2528 |
< |
advance(); |
2352 |
< |
Node e = last; |
2353 |
< |
if (e == null) |
2527 |
> |
Object k = nextKey; |
2528 |
> |
if (k == null && (advance() == null || (k = nextKey) == null)) |
2529 |
|
throw new IllegalStateException(); |
2530 |
< |
last = null; |
2356 |
< |
map.remove(e.key); |
2530 |
> |
map.internalReplace(k, null, null); |
2531 |
|
} |
2532 |
|
|
2533 |
|
public final boolean hasNext() { |
2631 |
|
} |
2632 |
|
|
2633 |
|
/** |
2634 |
+ |
* Creates a new {@link Set} backed by a ConcurrentHashMapV8 |
2635 |
+ |
* from the given type to {@code Boolean.TRUE}. |
2636 |
+ |
* |
2637 |
+ |
* @return the new set |
2638 |
+ |
*/ |
2639 |
+ |
public static <K> KeySetView<K,Boolean> newKeySet() { |
2640 |
+ |
return new KeySetView<K,Boolean>(new ConcurrentHashMapV8<K,Boolean>(), |
2641 |
+ |
Boolean.TRUE); |
2642 |
+ |
} |
2643 |
+ |
|
2644 |
+ |
/** |
2645 |
+ |
* Creates a new {@link Set} backed by a ConcurrentHashMapV8 |
2646 |
+ |
* from the given type to {@code Boolean.TRUE}. |
2647 |
+ |
* |
2648 |
+ |
* @param initialCapacity The implementation performs internal |
2649 |
+ |
* sizing to accommodate this many elements. |
2650 |
+ |
* @throws IllegalArgumentException if the initial capacity of |
2651 |
+ |
* elements is negative |
2652 |
+ |
* @return the new set |
2653 |
+ |
*/ |
2654 |
+ |
public static <K> KeySetView<K,Boolean> newKeySet(int initialCapacity) { |
2655 |
+ |
return new KeySetView<K,Boolean>(new ConcurrentHashMapV8<K,Boolean>(initialCapacity), |
2656 |
+ |
Boolean.TRUE); |
2657 |
+ |
} |
2658 |
+ |
|
2659 |
+ |
/** |
2660 |
|
* {@inheritDoc} |
2661 |
|
*/ |
2662 |
|
public boolean isEmpty() { |
2675 |
|
|
2676 |
|
/** |
2677 |
|
* Returns the number of mappings. This method should be used |
2678 |
< |
* instead of {@link #size} because a ConcurrentHashMap may |
2678 |
> |
* instead of {@link #size} because a ConcurrentHashMapV8 may |
2679 |
|
* contain more mappings than can be represented as an int. The |
2680 |
|
* value returned is a snapshot; the actual count may differ if |
2681 |
|
* there are ongoing concurrent insertions or removals. |
3048 |
|
/** |
3049 |
|
* Returns a {@link Set} view of the keys contained in this map. |
3050 |
|
* The set is backed by the map, so changes to the map are |
3051 |
< |
* reflected in the set, and vice-versa. The set supports element |
2852 |
< |
* removal, which removes the corresponding mapping from this map, |
2853 |
< |
* via the {@code Iterator.remove}, {@code Set.remove}, |
2854 |
< |
* {@code removeAll}, {@code retainAll}, and {@code clear} |
2855 |
< |
* operations. It does not support the {@code add} or |
2856 |
< |
* {@code addAll} operations. |
3051 |
> |
* reflected in the set, and vice-versa. |
3052 |
|
* |
3053 |
< |
* <p>The view's {@code iterator} is a "weakly consistent" iterator |
3054 |
< |
* that will never throw {@link ConcurrentModificationException}, |
3055 |
< |
* and guarantees to traverse elements as they existed upon |
3056 |
< |
* construction of the iterator, and may (but is not guaranteed to) |
3057 |
< |
* reflect any modifications subsequent to construction. |
3053 |
> |
* @return the set view |
3054 |
> |
*/ |
3055 |
> |
public KeySetView<K,V> keySet() { |
3056 |
> |
KeySetView<K,V> ks = keySet; |
3057 |
> |
return (ks != null) ? ks : (keySet = new KeySetView<K,V>(this, null)); |
3058 |
> |
} |
3059 |
> |
|
3060 |
> |
/** |
3061 |
> |
* Returns a {@link Set} view of the keys in this map, using the |
3062 |
> |
* given common mapped value for any additions (i.e., {@link |
3063 |
> |
* Collection#add} and {@link Collection#addAll}). This is of |
3064 |
> |
* course only appropriate if it is acceptable to use the same |
3065 |
> |
* value for all additions from this view. |
3066 |
> |
* |
3067 |
> |
* @param mappedValue the mapped value to use for any |
3068 |
> |
* additions. |
3069 |
> |
* @return the set view |
3070 |
> |
* @throws NullPointerException if the mappedValue is null |
3071 |
|
*/ |
3072 |
< |
public Set<K> keySet() { |
3073 |
< |
KeySet<K,V> ks = keySet; |
3074 |
< |
return (ks != null) ? ks : (keySet = new KeySet<K,V>(this)); |
3072 |
> |
public KeySetView<K,V> keySet(V mappedValue) { |
3073 |
> |
if (mappedValue == null) |
3074 |
> |
throw new NullPointerException(); |
3075 |
> |
return new KeySetView<K,V>(this, mappedValue); |
3076 |
|
} |
3077 |
|
|
3078 |
|
/** |
3254 |
|
super(it); |
3255 |
|
} |
3256 |
|
public KeyIterator<K,V> split() { |
3257 |
< |
if (last != null || (next != null && nextVal == null)) |
3257 |
> |
if (nextKey != null) |
3258 |
|
throw new IllegalStateException(); |
3259 |
|
return new KeyIterator<K,V>(this); |
3260 |
|
} |
3276 |
|
super(it); |
3277 |
|
} |
3278 |
|
public ValueIterator<K,V> split() { |
3279 |
< |
if (last != null || (next != null && nextVal == null)) |
3279 |
> |
if (nextKey != null) |
3280 |
|
throw new IllegalStateException(); |
3281 |
|
return new ValueIterator<K,V>(this); |
3282 |
|
} |
3299 |
|
super(it); |
3300 |
|
} |
3301 |
|
public EntryIterator<K,V> split() { |
3302 |
< |
if (last != null || (next != null && nextVal == null)) |
3302 |
> |
if (nextKey != null) |
3303 |
|
throw new IllegalStateException(); |
3304 |
|
return new EntryIterator<K,V>(this); |
3305 |
|
} |
3487 |
|
|
3488 |
|
} |
3489 |
|
|
3281 |
– |
static final class KeySet<K,V> extends CHMView<K,V> implements Set<K> { |
3282 |
– |
KeySet(ConcurrentHashMapV8<K, V> map) { |
3283 |
– |
super(map); |
3284 |
– |
} |
3285 |
– |
public final boolean contains(Object o) { return map.containsKey(o); } |
3286 |
– |
public final boolean remove(Object o) { return map.remove(o) != null; } |
3287 |
– |
public final Iterator<K> iterator() { |
3288 |
– |
return new KeyIterator<K,V>(map); |
3289 |
– |
} |
3290 |
– |
public final boolean add(K e) { |
3291 |
– |
throw new UnsupportedOperationException(); |
3292 |
– |
} |
3293 |
– |
public final boolean addAll(Collection<? extends K> c) { |
3294 |
– |
throw new UnsupportedOperationException(); |
3295 |
– |
} |
3296 |
– |
public boolean equals(Object o) { |
3297 |
– |
Set<?> c; |
3298 |
– |
return ((o instanceof Set) && |
3299 |
– |
((c = (Set<?>)o) == this || |
3300 |
– |
(containsAll(c) && c.containsAll(this)))); |
3301 |
– |
} |
3302 |
– |
} |
3303 |
– |
|
3304 |
– |
|
3490 |
|
static final class Values<K,V> extends CHMView<K,V> |
3491 |
|
implements Collection<V> { |
3492 |
|
Values(ConcurrentHashMapV8<K, V> map) { super(map); } |
3716 |
|
// ------------------------------------------------------- |
3717 |
|
|
3718 |
|
/** |
3719 |
< |
* Returns an extended {@link Parallel} view of this map using the |
3535 |
< |
* given executor for bulk parallel operations. |
3719 |
> |
* Performs the given action for each (key, value). |
3720 |
|
* |
3721 |
< |
* @param executor the executor |
3538 |
< |
* @return a parallel view |
3721 |
> |
* @param action the action |
3722 |
|
*/ |
3723 |
< |
public Parallel parallel(ForkJoinPool executor) { |
3724 |
< |
return new Parallel(executor); |
3723 |
> |
public void forEach(BiAction<K,V> action) { |
3724 |
> |
ForkJoinTasks.forEach |
3725 |
> |
(this, action).invoke(); |
3726 |
|
} |
3727 |
|
|
3728 |
|
/** |
3729 |
< |
* An extended view of a ConcurrentHashMap supporting bulk |
3730 |
< |
* parallel operations. These operations are designed to be |
3731 |
< |
* safely, and often sensibly, applied even with maps that are |
3732 |
< |
* being concurrently updated by other threads; for example, when |
3733 |
< |
* computing a snapshot summary of the values in a shared |
3734 |
< |
* registry. There are three kinds of operation, each with four |
3735 |
< |
* forms, accepting functions with Keys, Values, Entries, and |
3552 |
< |
* (Key, Value) arguments and/or return values. Because the |
3553 |
< |
* elements of a ConcurrentHashMap are not ordered in any |
3554 |
< |
* particular way, and may be processed in different orders in |
3555 |
< |
* different parallel executions, the correctness of supplied |
3556 |
< |
* functions should not depend on any ordering, or on any other |
3557 |
< |
* objects or values that may transiently change while computation |
3558 |
< |
* is in progress; and except for forEach actions, should ideally |
3559 |
< |
* be side-effect-free. |
3560 |
< |
* |
3561 |
< |
* <ul> |
3562 |
< |
* <li> forEach: Perform a given action on each element. |
3563 |
< |
* A variant form applies a given transformation on each element |
3564 |
< |
* before performing the action.</li> |
3565 |
< |
* |
3566 |
< |
* <li> search: Return the first available non-null result of |
3567 |
< |
* applying a given function on each element; skipping further |
3568 |
< |
* search when a result is found.</li> |
3569 |
< |
* |
3570 |
< |
* <li> reduce: Accumulate each element. The supplied reduction |
3571 |
< |
* function cannot rely on ordering (more formally, it should be |
3572 |
< |
* both associative and commutative). There are five variants: |
3573 |
< |
* |
3574 |
< |
* <ul> |
3575 |
< |
* |
3576 |
< |
* <li> Plain reductions. (There is not a form of this method for |
3577 |
< |
* (key, value) function arguments since there is no corresponding |
3578 |
< |
* return type.)</li> |
3579 |
< |
* |
3580 |
< |
* <li> Mapped reductions that accumulate the results of a given |
3581 |
< |
* function applied to each element.</li> |
3582 |
< |
* |
3583 |
< |
* <li> Reductions to scalar doubles, longs, and ints, using a |
3584 |
< |
* given basis value.</li> |
3585 |
< |
* |
3586 |
< |
* </li> |
3587 |
< |
* </ul> |
3588 |
< |
* </ul> |
3589 |
< |
* |
3590 |
< |
* <p>The concurrency properties of the bulk operations follow |
3591 |
< |
* from those of ConcurrentHashMap: Any non-null result returned |
3592 |
< |
* from {@code get(key)} and related access methods bears a |
3593 |
< |
* happens-before relation with the associated insertion or |
3594 |
< |
* update. The result of any bulk operation reflects the |
3595 |
< |
* composition of these per-element relations (but is not |
3596 |
< |
* necessarily atomic with respect to the map as a whole unless it |
3597 |
< |
* is somehow known to be quiescent). Conversely, because keys |
3598 |
< |
* and values in the map are never null, null serves as a reliable |
3599 |
< |
* atomic indicator of the current lack of any result. To |
3600 |
< |
* maintain this property, null serves as an implicit basis for |
3601 |
< |
* all non-scalar reduction operations. For the double, long, and |
3602 |
< |
* int versions, the basis should be one that, when combined with |
3603 |
< |
* any other value, returns that other value (more formally, it |
3604 |
< |
* should be the identity element for the reduction). Most common |
3605 |
< |
* reductions have these properties; for example, computing a sum |
3606 |
< |
* with basis 0 or a minimum with basis MAX_VALUE. |
3607 |
< |
* |
3608 |
< |
* <p>Search and transformation functions provided as arguments |
3609 |
< |
* should similarly return null to indicate the lack of any result |
3610 |
< |
* (in which case it is not used). In the case of mapped |
3611 |
< |
* reductions, this also enables transformations to serve as |
3612 |
< |
* filters, returning null (or, in the case of primitive |
3613 |
< |
* specializations, the identity basis) if the element should not |
3614 |
< |
* be combined. You can create compound transformations and |
3615 |
< |
* filterings by composing them yourself under this "null means |
3616 |
< |
* there is nothing there now" rule before using them in search or |
3617 |
< |
* reduce operations. |
3618 |
< |
* |
3619 |
< |
* <p>Methods accepting and/or returning Entry arguments maintain |
3620 |
< |
* key-value associations. They may be useful for example when |
3621 |
< |
* finding the key for the greatest value. Note that "plain" Entry |
3622 |
< |
* arguments can be supplied using {@code new |
3623 |
< |
* AbstractMap.SimpleEntry(k,v)}. |
3624 |
< |
* |
3625 |
< |
* <p> Bulk operations may complete abruptly, throwing an |
3626 |
< |
* exception encountered in the application of a supplied |
3627 |
< |
* function. Bear in mind when handling such exceptions that other |
3628 |
< |
* concurrently executing functions could also have thrown |
3629 |
< |
* exceptions, or would have done so if the first exception had |
3630 |
< |
* not occurred. |
3631 |
< |
* |
3632 |
< |
* <p>Parallel speedups compared to sequential processing are |
3633 |
< |
* common but not guaranteed. Operations involving brief |
3634 |
< |
* functions on small maps may execute more slowly than sequential |
3635 |
< |
* loops if the underlying work to parallelize the computation is |
3636 |
< |
* more expensive than the computation itself. Similarly, |
3637 |
< |
* parallelization may not lead to much actual parallelism if all |
3638 |
< |
* processors are busy performing unrelated tasks. |
3639 |
< |
* |
3640 |
< |
* <p> All arguments to all task methods must be non-null. |
3641 |
< |
* |
3642 |
< |
* <p><em>jsr166e note: During transition, this class |
3643 |
< |
* uses nested functional interfaces with different names but the |
3644 |
< |
* same forms as those expected for JDK8.<em> |
3729 |
> |
* Performs the given action for each non-null transformation |
3730 |
> |
* of each (key, value). |
3731 |
> |
* |
3732 |
> |
* @param transformer a function returning the transformation |
3733 |
> |
* for an element, or null of there is no transformation (in |
3734 |
> |
* which case the action is not applied). |
3735 |
> |
* @param action the action |
3736 |
|
*/ |
3737 |
< |
public class Parallel { |
3738 |
< |
final ForkJoinPool fjp; |
3737 |
> |
public <U> void forEach(BiFun<? super K, ? super V, ? extends U> transformer, |
3738 |
> |
Action<U> action) { |
3739 |
> |
ForkJoinTasks.forEach |
3740 |
> |
(this, transformer, action).invoke(); |
3741 |
> |
} |
3742 |
|
|
3743 |
< |
/** |
3744 |
< |
* Returns an extended view of this map using the given |
3745 |
< |
* executor for bulk parallel operations. |
3746 |
< |
* |
3747 |
< |
* @param executor the executor |
3748 |
< |
*/ |
3749 |
< |
public Parallel(ForkJoinPool executor) { |
3750 |
< |
this.fjp = executor; |
3751 |
< |
} |
3743 |
> |
/** |
3744 |
> |
* Returns a non-null result from applying the given search |
3745 |
> |
* function on each (key, value), or null if none. Upon |
3746 |
> |
* success, further element processing is suppressed and the |
3747 |
> |
* results of any other parallel invocations of the search |
3748 |
> |
* function are ignored. |
3749 |
> |
* |
3750 |
> |
* @param searchFunction a function returning a non-null |
3751 |
> |
* result on success, else null |
3752 |
> |
* @return a non-null result from applying the given search |
3753 |
> |
* function on each (key, value), or null if none |
3754 |
> |
*/ |
3755 |
> |
public <U> U search(BiFun<? super K, ? super V, ? extends U> searchFunction) { |
3756 |
> |
return ForkJoinTasks.search |
3757 |
> |
(this, searchFunction).invoke(); |
3758 |
> |
} |
3759 |
|
|
3760 |
< |
/** |
3761 |
< |
* Performs the given action for each (key, value). |
3762 |
< |
* |
3763 |
< |
* @param action the action |
3764 |
< |
*/ |
3765 |
< |
public void forEach(BiAction<K,V> action) { |
3766 |
< |
fjp.invoke(ForkJoinTasks.forEach |
3767 |
< |
(ConcurrentHashMapV8.this, action)); |
3768 |
< |
} |
3760 |
> |
/** |
3761 |
> |
* Returns the result of accumulating the given transformation |
3762 |
> |
* of all (key, value) pairs using the given reducer to |
3763 |
> |
* combine values, or null if none. |
3764 |
> |
* |
3765 |
> |
* @param transformer a function returning the transformation |
3766 |
> |
* for an element, or null of there is no transformation (in |
3767 |
> |
* which case it is not combined). |
3768 |
> |
* @param reducer a commutative associative combining function |
3769 |
> |
* @return the result of accumulating the given transformation |
3770 |
> |
* of all (key, value) pairs |
3771 |
> |
*/ |
3772 |
> |
public <U> U reduce(BiFun<? super K, ? super V, ? extends U> transformer, |
3773 |
> |
BiFun<? super U, ? super U, ? extends U> reducer) { |
3774 |
> |
return ForkJoinTasks.reduce |
3775 |
> |
(this, transformer, reducer).invoke(); |
3776 |
> |
} |
3777 |
|
|
3778 |
< |
/** |
3779 |
< |
* Performs the given action for each non-null transformation |
3780 |
< |
* of each (key, value). |
3781 |
< |
* |
3782 |
< |
* @param transformer a function returning the transformation |
3783 |
< |
* for an element, or null of there is no transformation (in |
3784 |
< |
* which case the action is not applied) |
3785 |
< |
* @param action the action |
3786 |
< |
*/ |
3787 |
< |
public <U> void forEach(BiFun<? super K, ? super V, ? extends U> transformer, |
3788 |
< |
Action<U> action) { |
3789 |
< |
fjp.invoke(ForkJoinTasks.forEach |
3790 |
< |
(ConcurrentHashMapV8.this, transformer, action)); |
3791 |
< |
} |
3778 |
> |
/** |
3779 |
> |
* Returns the result of accumulating the given transformation |
3780 |
> |
* of all (key, value) pairs using the given reducer to |
3781 |
> |
* combine values, and the given basis as an identity value. |
3782 |
> |
* |
3783 |
> |
* @param transformer a function returning the transformation |
3784 |
> |
* for an element |
3785 |
> |
* @param basis the identity (initial default value) for the reduction |
3786 |
> |
* @param reducer a commutative associative combining function |
3787 |
> |
* @return the result of accumulating the given transformation |
3788 |
> |
* of all (key, value) pairs |
3789 |
> |
*/ |
3790 |
> |
public double reduceToDouble(ObjectByObjectToDouble<? super K, ? super V> transformer, |
3791 |
> |
double basis, |
3792 |
> |
DoubleByDoubleToDouble reducer) { |
3793 |
> |
return ForkJoinTasks.reduceToDouble |
3794 |
> |
(this, transformer, basis, reducer).invoke(); |
3795 |
> |
} |
3796 |
|
|
3797 |
< |
/** |
3798 |
< |
* Returns a non-null result from applying the given search |
3799 |
< |
* function on each (key, value), or null if none. Upon |
3800 |
< |
* success, further element processing is suppressed and the |
3801 |
< |
* results of any other parallel invocations of the search |
3802 |
< |
* function are ignored. |
3803 |
< |
* |
3804 |
< |
* @param searchFunction a function returning a non-null |
3805 |
< |
* result on success, else null |
3806 |
< |
* @return a non-null result from applying the given search |
3807 |
< |
* function on each (key, value), or null if none |
3808 |
< |
*/ |
3809 |
< |
public <U> U search(BiFun<? super K, ? super V, ? extends U> searchFunction) { |
3810 |
< |
return fjp.invoke(ForkJoinTasks.search |
3811 |
< |
(ConcurrentHashMapV8.this, searchFunction)); |
3812 |
< |
} |
3797 |
> |
/** |
3798 |
> |
* Returns the result of accumulating the given transformation |
3799 |
> |
* of all (key, value) pairs using the given reducer to |
3800 |
> |
* combine values, and the given basis as an identity value. |
3801 |
> |
* |
3802 |
> |
* @param transformer a function returning the transformation |
3803 |
> |
* for an element |
3804 |
> |
* @param basis the identity (initial default value) for the reduction |
3805 |
> |
* @param reducer a commutative associative combining function |
3806 |
> |
* @return the result of accumulating the given transformation |
3807 |
> |
* of all (key, value) pairs |
3808 |
> |
*/ |
3809 |
> |
public long reduceToLong(ObjectByObjectToLong<? super K, ? super V> transformer, |
3810 |
> |
long basis, |
3811 |
> |
LongByLongToLong reducer) { |
3812 |
> |
return ForkJoinTasks.reduceToLong |
3813 |
> |
(this, transformer, basis, reducer).invoke(); |
3814 |
> |
} |
3815 |
|
|
3816 |
< |
/** |
3817 |
< |
* Returns the result of accumulating the given transformation |
3818 |
< |
* of all (key, value) pairs using the given reducer to |
3819 |
< |
* combine values, or null if none. |
3820 |
< |
* |
3821 |
< |
* @param transformer a function returning the transformation |
3822 |
< |
* for an element, or null of there is no transformation (in |
3823 |
< |
* which case it is not combined) |
3824 |
< |
* @param reducer a commutative associative combining function |
3825 |
< |
* @return the result of accumulating the given transformation |
3826 |
< |
* of all (key, value) pairs |
3827 |
< |
*/ |
3828 |
< |
public <U> U reduce(BiFun<? super K, ? super V, ? extends U> transformer, |
3816 |
> |
/** |
3817 |
> |
* Returns the result of accumulating the given transformation |
3818 |
> |
* of all (key, value) pairs using the given reducer to |
3819 |
> |
* combine values, and the given basis as an identity value. |
3820 |
> |
* |
3821 |
> |
* @param transformer a function returning the transformation |
3822 |
> |
* for an element |
3823 |
> |
* @param basis the identity (initial default value) for the reduction |
3824 |
> |
* @param reducer a commutative associative combining function |
3825 |
> |
* @return the result of accumulating the given transformation |
3826 |
> |
* of all (key, value) pairs |
3827 |
> |
*/ |
3828 |
> |
public int reduceToInt(ObjectByObjectToInt<? super K, ? super V> transformer, |
3829 |
> |
int basis, |
3830 |
> |
IntByIntToInt reducer) { |
3831 |
> |
return ForkJoinTasks.reduceToInt |
3832 |
> |
(this, transformer, basis, reducer).invoke(); |
3833 |
> |
} |
3834 |
> |
|
3835 |
> |
/** |
3836 |
> |
* Performs the given action for each key. |
3837 |
> |
* |
3838 |
> |
* @param action the action |
3839 |
> |
*/ |
3840 |
> |
public void forEachKey(Action<K> action) { |
3841 |
> |
ForkJoinTasks.forEachKey |
3842 |
> |
(this, action).invoke(); |
3843 |
> |
} |
3844 |
> |
|
3845 |
> |
/** |
3846 |
> |
* Performs the given action for each non-null transformation |
3847 |
> |
* of each key. |
3848 |
> |
* |
3849 |
> |
* @param transformer a function returning the transformation |
3850 |
> |
* for an element, or null of there is no transformation (in |
3851 |
> |
* which case the action is not applied). |
3852 |
> |
* @param action the action |
3853 |
> |
*/ |
3854 |
> |
public <U> void forEachKey(Fun<? super K, ? extends U> transformer, |
3855 |
> |
Action<U> action) { |
3856 |
> |
ForkJoinTasks.forEachKey |
3857 |
> |
(this, transformer, action).invoke(); |
3858 |
> |
} |
3859 |
> |
|
3860 |
> |
/** |
3861 |
> |
* Returns a non-null result from applying the given search |
3862 |
> |
* function on each key, or null if none. Upon success, |
3863 |
> |
* further element processing is suppressed and the results of |
3864 |
> |
* any other parallel invocations of the search function are |
3865 |
> |
* ignored. |
3866 |
> |
* |
3867 |
> |
* @param searchFunction a function returning a non-null |
3868 |
> |
* result on success, else null |
3869 |
> |
* @return a non-null result from applying the given search |
3870 |
> |
* function on each key, or null if none |
3871 |
> |
*/ |
3872 |
> |
public <U> U searchKeys(Fun<? super K, ? extends U> searchFunction) { |
3873 |
> |
return ForkJoinTasks.searchKeys |
3874 |
> |
(this, searchFunction).invoke(); |
3875 |
> |
} |
3876 |
> |
|
3877 |
> |
/** |
3878 |
> |
* Returns the result of accumulating all keys using the given |
3879 |
> |
* reducer to combine values, or null if none. |
3880 |
> |
* |
3881 |
> |
* @param reducer a commutative associative combining function |
3882 |
> |
* @return the result of accumulating all keys using the given |
3883 |
> |
* reducer to combine values, or null if none |
3884 |
> |
*/ |
3885 |
> |
public K reduceKeys(BiFun<? super K, ? super K, ? extends K> reducer) { |
3886 |
> |
return ForkJoinTasks.reduceKeys |
3887 |
> |
(this, reducer).invoke(); |
3888 |
> |
} |
3889 |
> |
|
3890 |
> |
/** |
3891 |
> |
* Returns the result of accumulating the given transformation |
3892 |
> |
* of all keys using the given reducer to combine values, or |
3893 |
> |
* null if none. |
3894 |
> |
* |
3895 |
> |
* @param transformer a function returning the transformation |
3896 |
> |
* for an element, or null of there is no transformation (in |
3897 |
> |
* which case it is not combined). |
3898 |
> |
* @param reducer a commutative associative combining function |
3899 |
> |
* @return the result of accumulating the given transformation |
3900 |
> |
* of all keys |
3901 |
> |
*/ |
3902 |
> |
public <U> U reduceKeys(Fun<? super K, ? extends U> transformer, |
3903 |
|
BiFun<? super U, ? super U, ? extends U> reducer) { |
3904 |
< |
return fjp.invoke(ForkJoinTasks.reduce |
3905 |
< |
(ConcurrentHashMapV8.this, transformer, reducer)); |
3906 |
< |
} |
3904 |
> |
return ForkJoinTasks.reduceKeys |
3905 |
> |
(this, transformer, reducer).invoke(); |
3906 |
> |
} |
3907 |
|
|
3908 |
< |
/** |
3909 |
< |
* Returns the result of accumulating the given transformation |
3910 |
< |
* of all (key, value) pairs using the given reducer to |
3911 |
< |
* combine values, and the given basis as an identity value. |
3912 |
< |
* |
3913 |
< |
* @param transformer a function returning the transformation |
3914 |
< |
* for an element |
3915 |
< |
* @param basis the identity (initial default value) for the reduction |
3916 |
< |
* @param reducer a commutative associative combining function |
3917 |
< |
* @return the result of accumulating the given transformation |
3918 |
< |
* of all (key, value) pairs |
3919 |
< |
*/ |
3920 |
< |
public double reduceToDouble(ObjectByObjectToDouble<? super K, ? super V> transformer, |
3908 |
> |
/** |
3909 |
> |
* Returns the result of accumulating the given transformation |
3910 |
> |
* of all keys using the given reducer to combine values, and |
3911 |
> |
* the given basis as an identity value. |
3912 |
> |
* |
3913 |
> |
* @param transformer a function returning the transformation |
3914 |
> |
* for an element |
3915 |
> |
* @param basis the identity (initial default value) for the reduction |
3916 |
> |
* @param reducer a commutative associative combining function |
3917 |
> |
* @return the result of accumulating the given transformation |
3918 |
> |
* of all keys |
3919 |
> |
*/ |
3920 |
> |
public double reduceKeysToDouble(ObjectToDouble<? super K> transformer, |
3921 |
|
double basis, |
3922 |
|
DoubleByDoubleToDouble reducer) { |
3923 |
< |
return fjp.invoke(ForkJoinTasks.reduceToDouble |
3924 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
3925 |
< |
} |
3923 |
> |
return ForkJoinTasks.reduceKeysToDouble |
3924 |
> |
(this, transformer, basis, reducer).invoke(); |
3925 |
> |
} |
3926 |
|
|
3927 |
< |
/** |
3928 |
< |
* Returns the result of accumulating the given transformation |
3929 |
< |
* of all (key, value) pairs using the given reducer to |
3930 |
< |
* combine values, and the given basis as an identity value. |
3931 |
< |
* |
3932 |
< |
* @param transformer a function returning the transformation |
3933 |
< |
* for an element |
3934 |
< |
* @param basis the identity (initial default value) for the reduction |
3935 |
< |
* @param reducer a commutative associative combining function |
3936 |
< |
* @return the result of accumulating the given transformation |
3937 |
< |
* of all (key, value) pairs |
3938 |
< |
*/ |
3939 |
< |
public long reduceToLong(ObjectByObjectToLong<? super K, ? super V> transformer, |
3927 |
> |
/** |
3928 |
> |
* Returns the result of accumulating the given transformation |
3929 |
> |
* of all keys using the given reducer to combine values, and |
3930 |
> |
* the given basis as an identity value. |
3931 |
> |
* |
3932 |
> |
* @param transformer a function returning the transformation |
3933 |
> |
* for an element |
3934 |
> |
* @param basis the identity (initial default value) for the reduction |
3935 |
> |
* @param reducer a commutative associative combining function |
3936 |
> |
* @return the result of accumulating the given transformation |
3937 |
> |
* of all keys |
3938 |
> |
*/ |
3939 |
> |
public long reduceKeysToLong(ObjectToLong<? super K> transformer, |
3940 |
|
long basis, |
3941 |
|
LongByLongToLong reducer) { |
3942 |
< |
return fjp.invoke(ForkJoinTasks.reduceToLong |
3943 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
3944 |
< |
} |
3942 |
> |
return ForkJoinTasks.reduceKeysToLong |
3943 |
> |
(this, transformer, basis, reducer).invoke(); |
3944 |
> |
} |
3945 |
|
|
3946 |
< |
/** |
3947 |
< |
* Returns the result of accumulating the given transformation |
3948 |
< |
* of all (key, value) pairs using the given reducer to |
3949 |
< |
* combine values, and the given basis as an identity value. |
3950 |
< |
* |
3951 |
< |
* @param transformer a function returning the transformation |
3952 |
< |
* for an element |
3953 |
< |
* @param basis the identity (initial default value) for the reduction |
3954 |
< |
* @param reducer a commutative associative combining function |
3955 |
< |
* @return the result of accumulating the given transformation |
3956 |
< |
* of all (key, value) pairs |
3957 |
< |
*/ |
3958 |
< |
public int reduceToInt(ObjectByObjectToInt<? super K, ? super V> transformer, |
3946 |
> |
/** |
3947 |
> |
* Returns the result of accumulating the given transformation |
3948 |
> |
* of all keys using the given reducer to combine values, and |
3949 |
> |
* the given basis as an identity value. |
3950 |
> |
* |
3951 |
> |
* @param transformer a function returning the transformation |
3952 |
> |
* for an element |
3953 |
> |
* @param basis the identity (initial default value) for the reduction |
3954 |
> |
* @param reducer a commutative associative combining function |
3955 |
> |
* @return the result of accumulating the given transformation |
3956 |
> |
* of all keys |
3957 |
> |
*/ |
3958 |
> |
public int reduceKeysToInt(ObjectToInt<? super K> transformer, |
3959 |
|
int basis, |
3960 |
|
IntByIntToInt reducer) { |
3961 |
< |
return fjp.invoke(ForkJoinTasks.reduceToInt |
3962 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
3963 |
< |
} |
3775 |
< |
|
3776 |
< |
/** |
3777 |
< |
* Performs the given action for each key. |
3778 |
< |
* |
3779 |
< |
* @param action the action |
3780 |
< |
*/ |
3781 |
< |
public void forEachKey(Action<K> action) { |
3782 |
< |
fjp.invoke(ForkJoinTasks.forEachKey |
3783 |
< |
(ConcurrentHashMapV8.this, action)); |
3784 |
< |
} |
3785 |
< |
|
3786 |
< |
/** |
3787 |
< |
* Performs the given action for each non-null transformation |
3788 |
< |
* of each key. |
3789 |
< |
* |
3790 |
< |
* @param transformer a function returning the transformation |
3791 |
< |
* for an element, or null of there is no transformation (in |
3792 |
< |
* which case the action is not applied) |
3793 |
< |
* @param action the action |
3794 |
< |
*/ |
3795 |
< |
public <U> void forEachKey(Fun<? super K, ? extends U> transformer, |
3796 |
< |
Action<U> action) { |
3797 |
< |
fjp.invoke(ForkJoinTasks.forEachKey |
3798 |
< |
(ConcurrentHashMapV8.this, transformer, action)); |
3799 |
< |
} |
3800 |
< |
|
3801 |
< |
/** |
3802 |
< |
* Returns a non-null result from applying the given search |
3803 |
< |
* function on each key, or null if none. Upon success, |
3804 |
< |
* further element processing is suppressed and the results of |
3805 |
< |
* any other parallel invocations of the search function are |
3806 |
< |
* ignored. |
3807 |
< |
* |
3808 |
< |
* @param searchFunction a function returning a non-null |
3809 |
< |
* result on success, else null |
3810 |
< |
* @return a non-null result from applying the given search |
3811 |
< |
* function on each key, or null if none |
3812 |
< |
*/ |
3813 |
< |
public <U> U searchKeys(Fun<? super K, ? extends U> searchFunction) { |
3814 |
< |
return fjp.invoke(ForkJoinTasks.searchKeys |
3815 |
< |
(ConcurrentHashMapV8.this, searchFunction)); |
3816 |
< |
} |
3817 |
< |
|
3818 |
< |
/** |
3819 |
< |
* Returns the result of accumulating all keys using the given |
3820 |
< |
* reducer to combine values, or null if none. |
3821 |
< |
* |
3822 |
< |
* @param reducer a commutative associative combining function |
3823 |
< |
* @return the result of accumulating all keys using the given |
3824 |
< |
* reducer to combine values, or null if none |
3825 |
< |
*/ |
3826 |
< |
public K reduceKeys(BiFun<? super K, ? super K, ? extends K> reducer) { |
3827 |
< |
return fjp.invoke(ForkJoinTasks.reduceKeys |
3828 |
< |
(ConcurrentHashMapV8.this, reducer)); |
3829 |
< |
} |
3830 |
< |
|
3831 |
< |
/** |
3832 |
< |
* Returns the result of accumulating the given transformation |
3833 |
< |
* of all keys using the given reducer to combine values, or |
3834 |
< |
* null if none. |
3835 |
< |
* |
3836 |
< |
* @param transformer a function returning the transformation |
3837 |
< |
* for an element, or null of there is no transformation (in |
3838 |
< |
* which case it is not combined) |
3839 |
< |
* @param reducer a commutative associative combining function |
3840 |
< |
* @return the result of accumulating the given transformation |
3841 |
< |
* of all keys |
3842 |
< |
*/ |
3843 |
< |
public <U> U reduceKeys(Fun<? super K, ? extends U> transformer, |
3844 |
< |
BiFun<? super U, ? super U, ? extends U> reducer) { |
3845 |
< |
return fjp.invoke(ForkJoinTasks.reduceKeys |
3846 |
< |
(ConcurrentHashMapV8.this, transformer, reducer)); |
3847 |
< |
} |
3848 |
< |
|
3849 |
< |
/** |
3850 |
< |
* Returns the result of accumulating the given transformation |
3851 |
< |
* of all keys using the given reducer to combine values, and |
3852 |
< |
* the given basis as an identity value. |
3853 |
< |
* |
3854 |
< |
* @param transformer a function returning the transformation |
3855 |
< |
* for an element |
3856 |
< |
* @param basis the identity (initial default value) for the reduction |
3857 |
< |
* @param reducer a commutative associative combining function |
3858 |
< |
* @return the result of accumulating the given transformation |
3859 |
< |
* of all keys |
3860 |
< |
*/ |
3861 |
< |
public double reduceKeysToDouble(ObjectToDouble<? super K> transformer, |
3862 |
< |
double basis, |
3863 |
< |
DoubleByDoubleToDouble reducer) { |
3864 |
< |
return fjp.invoke(ForkJoinTasks.reduceKeysToDouble |
3865 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
3866 |
< |
} |
3867 |
< |
|
3868 |
< |
/** |
3869 |
< |
* Returns the result of accumulating the given transformation |
3870 |
< |
* of all keys using the given reducer to combine values, and |
3871 |
< |
* the given basis as an identity value. |
3872 |
< |
* |
3873 |
< |
* @param transformer a function returning the transformation |
3874 |
< |
* for an element |
3875 |
< |
* @param basis the identity (initial default value) for the reduction |
3876 |
< |
* @param reducer a commutative associative combining function |
3877 |
< |
* @return the result of accumulating the given transformation |
3878 |
< |
* of all keys |
3879 |
< |
*/ |
3880 |
< |
public long reduceKeysToLong(ObjectToLong<? super K> transformer, |
3881 |
< |
long basis, |
3882 |
< |
LongByLongToLong reducer) { |
3883 |
< |
return fjp.invoke(ForkJoinTasks.reduceKeysToLong |
3884 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
3885 |
< |
} |
3886 |
< |
|
3887 |
< |
/** |
3888 |
< |
* Returns the result of accumulating the given transformation |
3889 |
< |
* of all keys using the given reducer to combine values, and |
3890 |
< |
* the given basis as an identity value. |
3891 |
< |
* |
3892 |
< |
* @param transformer a function returning the transformation |
3893 |
< |
* for an element |
3894 |
< |
* @param basis the identity (initial default value) for the reduction |
3895 |
< |
* @param reducer a commutative associative combining function |
3896 |
< |
* @return the result of accumulating the given transformation |
3897 |
< |
* of all keys |
3898 |
< |
*/ |
3899 |
< |
public int reduceKeysToInt(ObjectToInt<? super K> transformer, |
3900 |
< |
int basis, |
3901 |
< |
IntByIntToInt reducer) { |
3902 |
< |
return fjp.invoke(ForkJoinTasks.reduceKeysToInt |
3903 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
3904 |
< |
} |
3961 |
> |
return ForkJoinTasks.reduceKeysToInt |
3962 |
> |
(this, transformer, basis, reducer).invoke(); |
3963 |
> |
} |
3964 |
|
|
3965 |
< |
/** |
3966 |
< |
* Performs the given action for each value. |
3967 |
< |
* |
3968 |
< |
* @param action the action |
3969 |
< |
*/ |
3970 |
< |
public void forEachValue(Action<V> action) { |
3971 |
< |
fjp.invoke(ForkJoinTasks.forEachValue |
3972 |
< |
(ConcurrentHashMapV8.this, action)); |
3973 |
< |
} |
3965 |
> |
/** |
3966 |
> |
* Performs the given action for each value. |
3967 |
> |
* |
3968 |
> |
* @param action the action |
3969 |
> |
*/ |
3970 |
> |
public void forEachValue(Action<V> action) { |
3971 |
> |
ForkJoinTasks.forEachValue |
3972 |
> |
(this, action).invoke(); |
3973 |
> |
} |
3974 |
|
|
3975 |
< |
/** |
3976 |
< |
* Performs the given action for each non-null transformation |
3977 |
< |
* of each value. |
3978 |
< |
* |
3979 |
< |
* @param transformer a function returning the transformation |
3980 |
< |
* for an element, or null of there is no transformation (in |
3981 |
< |
* which case the action is not applied) |
3982 |
< |
*/ |
3983 |
< |
public <U> void forEachValue(Fun<? super V, ? extends U> transformer, |
3984 |
< |
Action<U> action) { |
3985 |
< |
fjp.invoke(ForkJoinTasks.forEachValue |
3986 |
< |
(ConcurrentHashMapV8.this, transformer, action)); |
3987 |
< |
} |
3975 |
> |
/** |
3976 |
> |
* Performs the given action for each non-null transformation |
3977 |
> |
* of each value. |
3978 |
> |
* |
3979 |
> |
* @param transformer a function returning the transformation |
3980 |
> |
* for an element, or null of there is no transformation (in |
3981 |
> |
* which case the action is not applied). |
3982 |
> |
*/ |
3983 |
> |
public <U> void forEachValue(Fun<? super V, ? extends U> transformer, |
3984 |
> |
Action<U> action) { |
3985 |
> |
ForkJoinTasks.forEachValue |
3986 |
> |
(this, transformer, action).invoke(); |
3987 |
> |
} |
3988 |
|
|
3989 |
< |
/** |
3990 |
< |
* Returns a non-null result from applying the given search |
3991 |
< |
* function on each value, or null if none. Upon success, |
3992 |
< |
* further element processing is suppressed and the results of |
3993 |
< |
* any other parallel invocations of the search function are |
3994 |
< |
* ignored. |
3995 |
< |
* |
3996 |
< |
* @param searchFunction a function returning a non-null |
3997 |
< |
* result on success, else null |
3998 |
< |
* @return a non-null result from applying the given search |
3999 |
< |
* function on each value, or null if none |
4000 |
< |
* |
4001 |
< |
*/ |
4002 |
< |
public <U> U searchValues(Fun<? super V, ? extends U> searchFunction) { |
4003 |
< |
return fjp.invoke(ForkJoinTasks.searchValues |
4004 |
< |
(ConcurrentHashMapV8.this, searchFunction)); |
4005 |
< |
} |
3989 |
> |
/** |
3990 |
> |
* Returns a non-null result from applying the given search |
3991 |
> |
* function on each value, or null if none. Upon success, |
3992 |
> |
* further element processing is suppressed and the results of |
3993 |
> |
* any other parallel invocations of the search function are |
3994 |
> |
* ignored. |
3995 |
> |
* |
3996 |
> |
* @param searchFunction a function returning a non-null |
3997 |
> |
* result on success, else null |
3998 |
> |
* @return a non-null result from applying the given search |
3999 |
> |
* function on each value, or null if none |
4000 |
> |
* |
4001 |
> |
*/ |
4002 |
> |
public <U> U searchValues(Fun<? super V, ? extends U> searchFunction) { |
4003 |
> |
return ForkJoinTasks.searchValues |
4004 |
> |
(this, searchFunction).invoke(); |
4005 |
> |
} |
4006 |
|
|
4007 |
< |
/** |
4008 |
< |
* Returns the result of accumulating all values using the |
4009 |
< |
* given reducer to combine values, or null if none. |
4010 |
< |
* |
4011 |
< |
* @param reducer a commutative associative combining function |
4012 |
< |
* @return the result of accumulating all values |
4013 |
< |
*/ |
4014 |
< |
public V reduceValues(BiFun<? super V, ? super V, ? extends V> reducer) { |
4015 |
< |
return fjp.invoke(ForkJoinTasks.reduceValues |
4016 |
< |
(ConcurrentHashMapV8.this, reducer)); |
4017 |
< |
} |
4007 |
> |
/** |
4008 |
> |
* Returns the result of accumulating all values using the |
4009 |
> |
* given reducer to combine values, or null if none. |
4010 |
> |
* |
4011 |
> |
* @param reducer a commutative associative combining function |
4012 |
> |
* @return the result of accumulating all values |
4013 |
> |
*/ |
4014 |
> |
public V reduceValues(BiFun<? super V, ? super V, ? extends V> reducer) { |
4015 |
> |
return ForkJoinTasks.reduceValues |
4016 |
> |
(this, reducer).invoke(); |
4017 |
> |
} |
4018 |
|
|
4019 |
< |
/** |
4020 |
< |
* Returns the result of accumulating the given transformation |
4021 |
< |
* of all values using the given reducer to combine values, or |
4022 |
< |
* null if none. |
4023 |
< |
* |
4024 |
< |
* @param transformer a function returning the transformation |
4025 |
< |
* for an element, or null of there is no transformation (in |
4026 |
< |
* which case it is not combined) |
4027 |
< |
* @param reducer a commutative associative combining function |
4028 |
< |
* @return the result of accumulating the given transformation |
4029 |
< |
* of all values |
4030 |
< |
*/ |
4031 |
< |
public <U> U reduceValues(Fun<? super V, ? extends U> transformer, |
4032 |
< |
BiFun<? super U, ? super U, ? extends U> reducer) { |
4033 |
< |
return fjp.invoke(ForkJoinTasks.reduceValues |
4034 |
< |
(ConcurrentHashMapV8.this, transformer, reducer)); |
4035 |
< |
} |
4019 |
> |
/** |
4020 |
> |
* Returns the result of accumulating the given transformation |
4021 |
> |
* of all values using the given reducer to combine values, or |
4022 |
> |
* null if none. |
4023 |
> |
* |
4024 |
> |
* @param transformer a function returning the transformation |
4025 |
> |
* for an element, or null of there is no transformation (in |
4026 |
> |
* which case it is not combined). |
4027 |
> |
* @param reducer a commutative associative combining function |
4028 |
> |
* @return the result of accumulating the given transformation |
4029 |
> |
* of all values |
4030 |
> |
*/ |
4031 |
> |
public <U> U reduceValues(Fun<? super V, ? extends U> transformer, |
4032 |
> |
BiFun<? super U, ? super U, ? extends U> reducer) { |
4033 |
> |
return ForkJoinTasks.reduceValues |
4034 |
> |
(this, transformer, reducer).invoke(); |
4035 |
> |
} |
4036 |
|
|
4037 |
< |
/** |
4038 |
< |
* Returns the result of accumulating the given transformation |
4039 |
< |
* of all values using the given reducer to combine values, |
4040 |
< |
* and the given basis as an identity value. |
4041 |
< |
* |
4042 |
< |
* @param transformer a function returning the transformation |
4043 |
< |
* for an element |
4044 |
< |
* @param basis the identity (initial default value) for the reduction |
4045 |
< |
* @param reducer a commutative associative combining function |
4046 |
< |
* @return the result of accumulating the given transformation |
4047 |
< |
* of all values |
4048 |
< |
*/ |
4049 |
< |
public double reduceValuesToDouble(ObjectToDouble<? super V> transformer, |
4050 |
< |
double basis, |
4051 |
< |
DoubleByDoubleToDouble reducer) { |
4052 |
< |
return fjp.invoke(ForkJoinTasks.reduceValuesToDouble |
4053 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
4054 |
< |
} |
4037 |
> |
/** |
4038 |
> |
* Returns the result of accumulating the given transformation |
4039 |
> |
* of all values using the given reducer to combine values, |
4040 |
> |
* and the given basis as an identity value. |
4041 |
> |
* |
4042 |
> |
* @param transformer a function returning the transformation |
4043 |
> |
* for an element |
4044 |
> |
* @param basis the identity (initial default value) for the reduction |
4045 |
> |
* @param reducer a commutative associative combining function |
4046 |
> |
* @return the result of accumulating the given transformation |
4047 |
> |
* of all values |
4048 |
> |
*/ |
4049 |
> |
public double reduceValuesToDouble(ObjectToDouble<? super V> transformer, |
4050 |
> |
double basis, |
4051 |
> |
DoubleByDoubleToDouble reducer) { |
4052 |
> |
return ForkJoinTasks.reduceValuesToDouble |
4053 |
> |
(this, transformer, basis, reducer).invoke(); |
4054 |
> |
} |
4055 |
|
|
4056 |
< |
/** |
4057 |
< |
* Returns the result of accumulating the given transformation |
4058 |
< |
* of all values using the given reducer to combine values, |
4059 |
< |
* and the given basis as an identity value. |
4060 |
< |
* |
4061 |
< |
* @param transformer a function returning the transformation |
4062 |
< |
* for an element |
4063 |
< |
* @param basis the identity (initial default value) for the reduction |
4064 |
< |
* @param reducer a commutative associative combining function |
4065 |
< |
* @return the result of accumulating the given transformation |
4066 |
< |
* of all values |
4067 |
< |
*/ |
4068 |
< |
public long reduceValuesToLong(ObjectToLong<? super V> transformer, |
4069 |
< |
long basis, |
4070 |
< |
LongByLongToLong reducer) { |
4071 |
< |
return fjp.invoke(ForkJoinTasks.reduceValuesToLong |
4072 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
4073 |
< |
} |
4056 |
> |
/** |
4057 |
> |
* Returns the result of accumulating the given transformation |
4058 |
> |
* of all values using the given reducer to combine values, |
4059 |
> |
* and the given basis as an identity value. |
4060 |
> |
* |
4061 |
> |
* @param transformer a function returning the transformation |
4062 |
> |
* for an element |
4063 |
> |
* @param basis the identity (initial default value) for the reduction |
4064 |
> |
* @param reducer a commutative associative combining function |
4065 |
> |
* @return the result of accumulating the given transformation |
4066 |
> |
* of all values |
4067 |
> |
*/ |
4068 |
> |
public long reduceValuesToLong(ObjectToLong<? super V> transformer, |
4069 |
> |
long basis, |
4070 |
> |
LongByLongToLong reducer) { |
4071 |
> |
return ForkJoinTasks.reduceValuesToLong |
4072 |
> |
(this, transformer, basis, reducer).invoke(); |
4073 |
> |
} |
4074 |
|
|
4075 |
< |
/** |
4076 |
< |
* Returns the result of accumulating the given transformation |
4077 |
< |
* of all values using the given reducer to combine values, |
4078 |
< |
* and the given basis as an identity value. |
4079 |
< |
* |
4080 |
< |
* @param transformer a function returning the transformation |
4081 |
< |
* for an element |
4082 |
< |
* @param basis the identity (initial default value) for the reduction |
4083 |
< |
* @param reducer a commutative associative combining function |
4084 |
< |
* @return the result of accumulating the given transformation |
4085 |
< |
* of all values |
4086 |
< |
*/ |
4087 |
< |
public int reduceValuesToInt(ObjectToInt<? super V> transformer, |
4088 |
< |
int basis, |
4089 |
< |
IntByIntToInt reducer) { |
4090 |
< |
return fjp.invoke(ForkJoinTasks.reduceValuesToInt |
4091 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
4092 |
< |
} |
4075 |
> |
/** |
4076 |
> |
* Returns the result of accumulating the given transformation |
4077 |
> |
* of all values using the given reducer to combine values, |
4078 |
> |
* and the given basis as an identity value. |
4079 |
> |
* |
4080 |
> |
* @param transformer a function returning the transformation |
4081 |
> |
* for an element |
4082 |
> |
* @param basis the identity (initial default value) for the reduction |
4083 |
> |
* @param reducer a commutative associative combining function |
4084 |
> |
* @return the result of accumulating the given transformation |
4085 |
> |
* of all values |
4086 |
> |
*/ |
4087 |
> |
public int reduceValuesToInt(ObjectToInt<? super V> transformer, |
4088 |
> |
int basis, |
4089 |
> |
IntByIntToInt reducer) { |
4090 |
> |
return ForkJoinTasks.reduceValuesToInt |
4091 |
> |
(this, transformer, basis, reducer).invoke(); |
4092 |
> |
} |
4093 |
|
|
4094 |
< |
/** |
4095 |
< |
* Performs the given action for each entry. |
4096 |
< |
* |
4097 |
< |
* @param action the action |
4098 |
< |
*/ |
4099 |
< |
public void forEachEntry(Action<Map.Entry<K,V>> action) { |
4100 |
< |
fjp.invoke(ForkJoinTasks.forEachEntry |
4101 |
< |
(ConcurrentHashMapV8.this, action)); |
4102 |
< |
} |
4094 |
> |
/** |
4095 |
> |
* Performs the given action for each entry. |
4096 |
> |
* |
4097 |
> |
* @param action the action |
4098 |
> |
*/ |
4099 |
> |
public void forEachEntry(Action<Map.Entry<K,V>> action) { |
4100 |
> |
ForkJoinTasks.forEachEntry |
4101 |
> |
(this, action).invoke(); |
4102 |
> |
} |
4103 |
|
|
4104 |
< |
/** |
4105 |
< |
* Performs the given action for each non-null transformation |
4106 |
< |
* of each entry. |
4107 |
< |
* |
4108 |
< |
* @param transformer a function returning the transformation |
4109 |
< |
* for an element, or null of there is no transformation (in |
4110 |
< |
* which case the action is not applied) |
4111 |
< |
* @param action the action |
4112 |
< |
*/ |
4113 |
< |
public <U> void forEachEntry(Fun<Map.Entry<K,V>, ? extends U> transformer, |
4114 |
< |
Action<U> action) { |
4115 |
< |
fjp.invoke(ForkJoinTasks.forEachEntry |
4116 |
< |
(ConcurrentHashMapV8.this, transformer, action)); |
4117 |
< |
} |
4104 |
> |
/** |
4105 |
> |
* Performs the given action for each non-null transformation |
4106 |
> |
* of each entry. |
4107 |
> |
* |
4108 |
> |
* @param transformer a function returning the transformation |
4109 |
> |
* for an element, or null of there is no transformation (in |
4110 |
> |
* which case the action is not applied). |
4111 |
> |
* @param action the action |
4112 |
> |
*/ |
4113 |
> |
public <U> void forEachEntry(Fun<Map.Entry<K,V>, ? extends U> transformer, |
4114 |
> |
Action<U> action) { |
4115 |
> |
ForkJoinTasks.forEachEntry |
4116 |
> |
(this, transformer, action).invoke(); |
4117 |
> |
} |
4118 |
|
|
4119 |
< |
/** |
4120 |
< |
* Returns a non-null result from applying the given search |
4121 |
< |
* function on each entry, or null if none. Upon success, |
4122 |
< |
* further element processing is suppressed and the results of |
4123 |
< |
* any other parallel invocations of the search function are |
4124 |
< |
* ignored. |
4125 |
< |
* |
4126 |
< |
* @param searchFunction a function returning a non-null |
4127 |
< |
* result on success, else null |
4128 |
< |
* @return a non-null result from applying the given search |
4129 |
< |
* function on each entry, or null if none |
4130 |
< |
*/ |
4131 |
< |
public <U> U searchEntries(Fun<Map.Entry<K,V>, ? extends U> searchFunction) { |
4132 |
< |
return fjp.invoke(ForkJoinTasks.searchEntries |
4133 |
< |
(ConcurrentHashMapV8.this, searchFunction)); |
4134 |
< |
} |
4119 |
> |
/** |
4120 |
> |
* Returns a non-null result from applying the given search |
4121 |
> |
* function on each entry, or null if none. Upon success, |
4122 |
> |
* further element processing is suppressed and the results of |
4123 |
> |
* any other parallel invocations of the search function are |
4124 |
> |
* ignored. |
4125 |
> |
* |
4126 |
> |
* @param searchFunction a function returning a non-null |
4127 |
> |
* result on success, else null |
4128 |
> |
* @return a non-null result from applying the given search |
4129 |
> |
* function on each entry, or null if none |
4130 |
> |
*/ |
4131 |
> |
public <U> U searchEntries(Fun<Map.Entry<K,V>, ? extends U> searchFunction) { |
4132 |
> |
return ForkJoinTasks.searchEntries |
4133 |
> |
(this, searchFunction).invoke(); |
4134 |
> |
} |
4135 |
|
|
4136 |
< |
/** |
4137 |
< |
* Returns the result of accumulating all entries using the |
4138 |
< |
* given reducer to combine values, or null if none. |
4139 |
< |
* |
4140 |
< |
* @param reducer a commutative associative combining function |
4141 |
< |
* @return the result of accumulating all entries |
4142 |
< |
*/ |
4143 |
< |
public Map.Entry<K,V> reduceEntries(BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) { |
4144 |
< |
return fjp.invoke(ForkJoinTasks.reduceEntries |
4145 |
< |
(ConcurrentHashMapV8.this, reducer)); |
4146 |
< |
} |
4136 |
> |
/** |
4137 |
> |
* Returns the result of accumulating all entries using the |
4138 |
> |
* given reducer to combine values, or null if none. |
4139 |
> |
* |
4140 |
> |
* @param reducer a commutative associative combining function |
4141 |
> |
* @return the result of accumulating all entries |
4142 |
> |
*/ |
4143 |
> |
public Map.Entry<K,V> reduceEntries(BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) { |
4144 |
> |
return ForkJoinTasks.reduceEntries |
4145 |
> |
(this, reducer).invoke(); |
4146 |
> |
} |
4147 |
|
|
4148 |
< |
/** |
4149 |
< |
* Returns the result of accumulating the given transformation |
4150 |
< |
* of all entries using the given reducer to combine values, |
4151 |
< |
* or null if none. |
4152 |
< |
* |
4153 |
< |
* @param transformer a function returning the transformation |
4154 |
< |
* for an element, or null of there is no transformation (in |
4155 |
< |
* which case it is not combined). |
4156 |
< |
* @param reducer a commutative associative combining function |
4157 |
< |
* @return the result of accumulating the given transformation |
4158 |
< |
* of all entries |
4159 |
< |
*/ |
4160 |
< |
public <U> U reduceEntries(Fun<Map.Entry<K,V>, ? extends U> transformer, |
4161 |
< |
BiFun<? super U, ? super U, ? extends U> reducer) { |
4162 |
< |
return fjp.invoke(ForkJoinTasks.reduceEntries |
4163 |
< |
(ConcurrentHashMapV8.this, transformer, reducer)); |
4164 |
< |
} |
4148 |
> |
/** |
4149 |
> |
* Returns the result of accumulating the given transformation |
4150 |
> |
* of all entries using the given reducer to combine values, |
4151 |
> |
* or null if none. |
4152 |
> |
* |
4153 |
> |
* @param transformer a function returning the transformation |
4154 |
> |
* for an element, or null of there is no transformation (in |
4155 |
> |
* which case it is not combined). |
4156 |
> |
* @param reducer a commutative associative combining function |
4157 |
> |
* @return the result of accumulating the given transformation |
4158 |
> |
* of all entries |
4159 |
> |
*/ |
4160 |
> |
public <U> U reduceEntries(Fun<Map.Entry<K,V>, ? extends U> transformer, |
4161 |
> |
BiFun<? super U, ? super U, ? extends U> reducer) { |
4162 |
> |
return ForkJoinTasks.reduceEntries |
4163 |
> |
(this, transformer, reducer).invoke(); |
4164 |
> |
} |
4165 |
|
|
4166 |
< |
/** |
4167 |
< |
* Returns the result of accumulating the given transformation |
4168 |
< |
* of all entries using the given reducer to combine values, |
4169 |
< |
* and the given basis as an identity value. |
4170 |
< |
* |
4171 |
< |
* @param transformer a function returning the transformation |
4172 |
< |
* for an element |
4173 |
< |
* @param basis the identity (initial default value) for the reduction |
4174 |
< |
* @param reducer a commutative associative combining function |
4175 |
< |
* @return the result of accumulating the given transformation |
4176 |
< |
* of all entries |
4177 |
< |
*/ |
4178 |
< |
public double reduceEntriesToDouble(ObjectToDouble<Map.Entry<K,V>> transformer, |
4179 |
< |
double basis, |
4180 |
< |
DoubleByDoubleToDouble reducer) { |
4181 |
< |
return fjp.invoke(ForkJoinTasks.reduceEntriesToDouble |
4182 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
4183 |
< |
} |
4166 |
> |
/** |
4167 |
> |
* Returns the result of accumulating the given transformation |
4168 |
> |
* of all entries using the given reducer to combine values, |
4169 |
> |
* and the given basis as an identity value. |
4170 |
> |
* |
4171 |
> |
* @param transformer a function returning the transformation |
4172 |
> |
* for an element |
4173 |
> |
* @param basis the identity (initial default value) for the reduction |
4174 |
> |
* @param reducer a commutative associative combining function |
4175 |
> |
* @return the result of accumulating the given transformation |
4176 |
> |
* of all entries |
4177 |
> |
*/ |
4178 |
> |
public double reduceEntriesToDouble(ObjectToDouble<Map.Entry<K,V>> transformer, |
4179 |
> |
double basis, |
4180 |
> |
DoubleByDoubleToDouble reducer) { |
4181 |
> |
return ForkJoinTasks.reduceEntriesToDouble |
4182 |
> |
(this, transformer, basis, reducer).invoke(); |
4183 |
> |
} |
4184 |
|
|
4185 |
< |
/** |
4186 |
< |
* Returns the result of accumulating the given transformation |
4187 |
< |
* of all entries using the given reducer to combine values, |
4188 |
< |
* and the given basis as an identity value. |
4189 |
< |
* |
4190 |
< |
* @param transformer a function returning the transformation |
4191 |
< |
* for an element |
4192 |
< |
* @param basis the identity (initial default value) for the reduction |
4193 |
< |
* @param reducer a commutative associative combining function |
4194 |
< |
* @return the result of accumulating the given transformation |
4195 |
< |
* of all entries |
4196 |
< |
*/ |
4197 |
< |
public long reduceEntriesToLong(ObjectToLong<Map.Entry<K,V>> transformer, |
4198 |
< |
long basis, |
4199 |
< |
LongByLongToLong reducer) { |
4200 |
< |
return fjp.invoke(ForkJoinTasks.reduceEntriesToLong |
4201 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
4202 |
< |
} |
4185 |
> |
/** |
4186 |
> |
* Returns the result of accumulating the given transformation |
4187 |
> |
* of all entries using the given reducer to combine values, |
4188 |
> |
* and the given basis as an identity value. |
4189 |
> |
* |
4190 |
> |
* @param transformer a function returning the transformation |
4191 |
> |
* for an element |
4192 |
> |
* @param basis the identity (initial default value) for the reduction |
4193 |
> |
* @param reducer a commutative associative combining function |
4194 |
> |
* @return the result of accumulating the given transformation |
4195 |
> |
* of all entries |
4196 |
> |
*/ |
4197 |
> |
public long reduceEntriesToLong(ObjectToLong<Map.Entry<K,V>> transformer, |
4198 |
> |
long basis, |
4199 |
> |
LongByLongToLong reducer) { |
4200 |
> |
return ForkJoinTasks.reduceEntriesToLong |
4201 |
> |
(this, transformer, basis, reducer).invoke(); |
4202 |
> |
} |
4203 |
|
|
4204 |
< |
/** |
4205 |
< |
* Returns the result of accumulating the given transformation |
4206 |
< |
* of all entries using the given reducer to combine values, |
4207 |
< |
* and the given basis as an identity value. |
4208 |
< |
* |
4209 |
< |
* @param transformer a function returning the transformation |
4210 |
< |
* for an element |
4211 |
< |
* @param basis the identity (initial default value) for the reduction |
4212 |
< |
* @param reducer a commutative associative combining function |
4213 |
< |
* @return the result of accumulating the given transformation |
4214 |
< |
* of all entries |
4215 |
< |
*/ |
4216 |
< |
public int reduceEntriesToInt(ObjectToInt<Map.Entry<K,V>> transformer, |
4217 |
< |
int basis, |
4218 |
< |
IntByIntToInt reducer) { |
4219 |
< |
return fjp.invoke(ForkJoinTasks.reduceEntriesToInt |
4220 |
< |
(ConcurrentHashMapV8.this, transformer, basis, reducer)); |
4162 |
< |
} |
4204 |
> |
/** |
4205 |
> |
* Returns the result of accumulating the given transformation |
4206 |
> |
* of all entries using the given reducer to combine values, |
4207 |
> |
* and the given basis as an identity value. |
4208 |
> |
* |
4209 |
> |
* @param transformer a function returning the transformation |
4210 |
> |
* for an element |
4211 |
> |
* @param basis the identity (initial default value) for the reduction |
4212 |
> |
* @param reducer a commutative associative combining function |
4213 |
> |
* @return the result of accumulating the given transformation |
4214 |
> |
* of all entries |
4215 |
> |
*/ |
4216 |
> |
public int reduceEntriesToInt(ObjectToInt<Map.Entry<K,V>> transformer, |
4217 |
> |
int basis, |
4218 |
> |
IntByIntToInt reducer) { |
4219 |
> |
return ForkJoinTasks.reduceEntriesToInt |
4220 |
> |
(this, transformer, basis, reducer).invoke(); |
4221 |
|
} |
4222 |
|
|
4223 |
|
// --------------------------------------------------------------------- |
4224 |
|
|
4225 |
|
/** |
4226 |
|
* Predefined tasks for performing bulk parallel operations on |
4227 |
< |
* ConcurrentHashMaps. These tasks follow the forms and rules used |
4228 |
< |
* in class {@link Parallel}. Each method has the same name, but |
4229 |
< |
* returns a task rather than invoking it. These methods may be |
4230 |
< |
* useful in custom applications such as submitting a task without |
4231 |
< |
* waiting for completion, or combining with other tasks. |
4227 |
> |
* ConcurrentHashMapV8s. These tasks follow the forms and rules used |
4228 |
> |
* for bulk operations. Each method has the same name, but returns |
4229 |
> |
* a task rather than invoking it. These methods may be useful in |
4230 |
> |
* custom applications such as submitting a task without waiting |
4231 |
> |
* for completion, using a custom pool, or combining with other |
4232 |
> |
* tasks. |
4233 |
|
*/ |
4234 |
|
public static class ForkJoinTasks { |
4235 |
|
private ForkJoinTasks() {} |
4246 |
|
(ConcurrentHashMapV8<K,V> map, |
4247 |
|
BiAction<K,V> action) { |
4248 |
|
if (action == null) throw new NullPointerException(); |
4249 |
< |
return new ForEachMappingTask<K,V>(map, null, -1, action); |
4249 |
> |
return new ForEachMappingTask<K,V>(map, null, -1, null, action); |
4250 |
|
} |
4251 |
|
|
4252 |
|
/** |
4255 |
|
* |
4256 |
|
* @param map the map |
4257 |
|
* @param transformer a function returning the transformation |
4258 |
< |
* for an element, or null of there is no transformation (in |
4258 |
> |
* for an element, or null if there is no transformation (in |
4259 |
|
* which case the action is not applied) |
4260 |
|
* @param action the action |
4261 |
|
* @return the task |
4267 |
|
if (transformer == null || action == null) |
4268 |
|
throw new NullPointerException(); |
4269 |
|
return new ForEachTransformedMappingTask<K,V,U> |
4270 |
< |
(map, null, -1, transformer, action); |
4270 |
> |
(map, null, -1, null, transformer, action); |
4271 |
|
} |
4272 |
|
|
4273 |
|
/** |
4287 |
|
BiFun<? super K, ? super V, ? extends U> searchFunction) { |
4288 |
|
if (searchFunction == null) throw new NullPointerException(); |
4289 |
|
return new SearchMappingsTask<K,V,U> |
4290 |
< |
(map, null, -1, searchFunction, |
4290 |
> |
(map, null, -1, null, searchFunction, |
4291 |
|
new AtomicReference<U>()); |
4292 |
|
} |
4293 |
|
|
4298 |
|
* |
4299 |
|
* @param map the map |
4300 |
|
* @param transformer a function returning the transformation |
4301 |
< |
* for an element, or null of there is no transformation (in |
4301 |
> |
* for an element, or null if there is no transformation (in |
4302 |
|
* which case it is not combined). |
4303 |
|
* @param reducer a commutative associative combining function |
4304 |
|
* @return the task |
4396 |
|
(ConcurrentHashMapV8<K,V> map, |
4397 |
|
Action<K> action) { |
4398 |
|
if (action == null) throw new NullPointerException(); |
4399 |
< |
return new ForEachKeyTask<K,V>(map, null, -1, action); |
4399 |
> |
return new ForEachKeyTask<K,V>(map, null, -1, null, action); |
4400 |
|
} |
4401 |
|
|
4402 |
|
/** |
4405 |
|
* |
4406 |
|
* @param map the map |
4407 |
|
* @param transformer a function returning the transformation |
4408 |
< |
* for an element, or null of there is no transformation (in |
4408 |
> |
* for an element, or null if there is no transformation (in |
4409 |
|
* which case the action is not applied) |
4410 |
|
* @param action the action |
4411 |
|
* @return the task |
4417 |
|
if (transformer == null || action == null) |
4418 |
|
throw new NullPointerException(); |
4419 |
|
return new ForEachTransformedKeyTask<K,V,U> |
4420 |
< |
(map, null, -1, transformer, action); |
4420 |
> |
(map, null, -1, null, transformer, action); |
4421 |
|
} |
4422 |
|
|
4423 |
|
/** |
4437 |
|
Fun<? super K, ? extends U> searchFunction) { |
4438 |
|
if (searchFunction == null) throw new NullPointerException(); |
4439 |
|
return new SearchKeysTask<K,V,U> |
4440 |
< |
(map, null, -1, searchFunction, |
4440 |
> |
(map, null, -1, null, searchFunction, |
4441 |
|
new AtomicReference<U>()); |
4442 |
|
} |
4443 |
|
|
4465 |
|
* |
4466 |
|
* @param map the map |
4467 |
|
* @param transformer a function returning the transformation |
4468 |
< |
* for an element, or null of there is no transformation (in |
4468 |
> |
* for an element, or null if there is no transformation (in |
4469 |
|
* which case it is not combined). |
4470 |
|
* @param reducer a commutative associative combining function |
4471 |
|
* @return the task |
4563 |
|
(ConcurrentHashMapV8<K,V> map, |
4564 |
|
Action<V> action) { |
4565 |
|
if (action == null) throw new NullPointerException(); |
4566 |
< |
return new ForEachValueTask<K,V>(map, null, -1, action); |
4566 |
> |
return new ForEachValueTask<K,V>(map, null, -1, null, action); |
4567 |
|
} |
4568 |
|
|
4569 |
|
/** |
4572 |
|
* |
4573 |
|
* @param map the map |
4574 |
|
* @param transformer a function returning the transformation |
4575 |
< |
* for an element, or null of there is no transformation (in |
4575 |
> |
* for an element, or null if there is no transformation (in |
4576 |
|
* which case the action is not applied) |
4577 |
|
* @param action the action |
4578 |
|
*/ |
4583 |
|
if (transformer == null || action == null) |
4584 |
|
throw new NullPointerException(); |
4585 |
|
return new ForEachTransformedValueTask<K,V,U> |
4586 |
< |
(map, null, -1, transformer, action); |
4586 |
> |
(map, null, -1, null, transformer, action); |
4587 |
|
} |
4588 |
|
|
4589 |
|
/** |
4597 |
|
* @param searchFunction a function returning a non-null |
4598 |
|
* result on success, else null |
4599 |
|
* @return the task |
4541 |
– |
* |
4600 |
|
*/ |
4601 |
|
public static <K,V,U> ForkJoinTask<U> searchValues |
4602 |
|
(ConcurrentHashMapV8<K,V> map, |
4603 |
|
Fun<? super V, ? extends U> searchFunction) { |
4604 |
|
if (searchFunction == null) throw new NullPointerException(); |
4605 |
|
return new SearchValuesTask<K,V,U> |
4606 |
< |
(map, null, -1, searchFunction, |
4606 |
> |
(map, null, -1, null, searchFunction, |
4607 |
|
new AtomicReference<U>()); |
4608 |
|
} |
4609 |
|
|
4631 |
|
* |
4632 |
|
* @param map the map |
4633 |
|
* @param transformer a function returning the transformation |
4634 |
< |
* for an element, or null of there is no transformation (in |
4634 |
> |
* for an element, or null if there is no transformation (in |
4635 |
|
* which case it is not combined). |
4636 |
|
* @param reducer a commutative associative combining function |
4637 |
|
* @return the task |
4729 |
|
(ConcurrentHashMapV8<K,V> map, |
4730 |
|
Action<Map.Entry<K,V>> action) { |
4731 |
|
if (action == null) throw new NullPointerException(); |
4732 |
< |
return new ForEachEntryTask<K,V>(map, null, -1, action); |
4732 |
> |
return new ForEachEntryTask<K,V>(map, null, -1, null, action); |
4733 |
|
} |
4734 |
|
|
4735 |
|
/** |
4738 |
|
* |
4739 |
|
* @param map the map |
4740 |
|
* @param transformer a function returning the transformation |
4741 |
< |
* for an element, or null of there is no transformation (in |
4741 |
> |
* for an element, or null if there is no transformation (in |
4742 |
|
* which case the action is not applied) |
4743 |
|
* @param action the action |
4744 |
|
*/ |
4749 |
|
if (transformer == null || action == null) |
4750 |
|
throw new NullPointerException(); |
4751 |
|
return new ForEachTransformedEntryTask<K,V,U> |
4752 |
< |
(map, null, -1, transformer, action); |
4752 |
> |
(map, null, -1, null, transformer, action); |
4753 |
|
} |
4754 |
|
|
4755 |
|
/** |
4763 |
|
* @param searchFunction a function returning a non-null |
4764 |
|
* result on success, else null |
4765 |
|
* @return the task |
4708 |
– |
* |
4766 |
|
*/ |
4767 |
|
public static <K,V,U> ForkJoinTask<U> searchEntries |
4768 |
|
(ConcurrentHashMapV8<K,V> map, |
4769 |
|
Fun<Map.Entry<K,V>, ? extends U> searchFunction) { |
4770 |
|
if (searchFunction == null) throw new NullPointerException(); |
4771 |
|
return new SearchEntriesTask<K,V,U> |
4772 |
< |
(map, null, -1, searchFunction, |
4772 |
> |
(map, null, -1, null, searchFunction, |
4773 |
|
new AtomicReference<U>()); |
4774 |
|
} |
4775 |
|
|
4797 |
|
* |
4798 |
|
* @param map the map |
4799 |
|
* @param transformer a function returning the transformation |
4800 |
< |
* for an element, or null of there is no transformation (in |
4800 |
> |
* for an element, or null if there is no transformation (in |
4801 |
|
* which case it is not combined). |
4802 |
|
* @param reducer a commutative associative combining function |
4803 |
|
* @return the task |
4921 |
|
} |
4922 |
|
} |
4923 |
|
|
4867 |
– |
// FJ methods |
4868 |
– |
|
4869 |
– |
/** |
4870 |
– |
* Propagates completion. Note that all reduce actions |
4871 |
– |
* bypass this method to combine while completing. |
4872 |
– |
*/ |
4873 |
– |
final void tryComplete() { |
4874 |
– |
BulkTask<K,V,?> a = this, s = a; |
4875 |
– |
for (int c;;) { |
4876 |
– |
if ((c = a.pending) == 0) { |
4877 |
– |
if ((a = (s = a).parent) == null) { |
4878 |
– |
s.quietlyComplete(); |
4879 |
– |
break; |
4880 |
– |
} |
4881 |
– |
} |
4882 |
– |
else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) |
4883 |
– |
break; |
4884 |
– |
} |
4885 |
– |
} |
4886 |
– |
|
4924 |
|
/** |
4925 |
|
* Forces root task to complete. |
4926 |
|
* @param ex if null, complete normally, else exceptionally |
4962 |
|
* dividing by two anyway. |
4963 |
|
*/ |
4964 |
|
final int batch() { |
4965 |
< |
ConcurrentHashMapV8<K, V> m; int b; Node[] t; |
4965 |
> |
ConcurrentHashMapV8<K, V> m; int b; Node[] t; ForkJoinPool pool; |
4966 |
|
if ((b = batch) < 0 && (m = map) != null) { // force initialization |
4967 |
|
if ((t = tab) == null && (t = tab = m.table) != null) |
4968 |
|
baseLimit = baseSize = t.length; |
4969 |
|
if (t != null) { |
4970 |
|
long n = m.counter.sum(); |
4971 |
< |
int sp = getPool().getParallelism() << 3; // slack of 8 |
4971 |
> |
int par = (pool = getPool()) == null? |
4972 |
> |
ForkJoinPool.getCommonPoolParallelism() : |
4973 |
> |
pool.getParallelism(); |
4974 |
> |
int sp = par << 3; // slack of 8 |
4975 |
|
b = batch = (n <= 0L) ? 0 : (n < (long)sp) ? (int)n : sp; |
4976 |
|
} |
4977 |
|
} |
4999 |
|
} |
5000 |
|
} |
5001 |
|
|
5002 |
+ |
/** |
5003 |
+ |
* Base class for non-reductive actions |
5004 |
+ |
*/ |
5005 |
+ |
@SuppressWarnings("serial") static abstract class BulkAction<K,V,R> extends BulkTask<K,V,R> { |
5006 |
+ |
BulkAction<K,V,?> nextTask; |
5007 |
+ |
BulkAction(ConcurrentHashMapV8<K,V> map, BulkTask<K,V,?> parent, |
5008 |
+ |
int batch, BulkAction<K,V,?> nextTask) { |
5009 |
+ |
super(map, parent, batch); |
5010 |
+ |
this.nextTask = nextTask; |
5011 |
+ |
} |
5012 |
+ |
|
5013 |
+ |
/** |
5014 |
+ |
* Try to complete task and upward parents. Upon hitting |
5015 |
+ |
* non-completed parent, if a non-FJ task, try to help out the |
5016 |
+ |
* computation. |
5017 |
+ |
*/ |
5018 |
+ |
final void tryComplete(BulkAction<K,V,?> subtasks) { |
5019 |
+ |
BulkTask<K,V,?> a = this, s = a; |
5020 |
+ |
for (int c;;) { |
5021 |
+ |
if ((c = a.pending) == 0) { |
5022 |
+ |
if ((a = (s = a).parent) == null) { |
5023 |
+ |
s.quietlyComplete(); |
5024 |
+ |
break; |
5025 |
+ |
} |
5026 |
+ |
} |
5027 |
+ |
else if (a.casPending(c, c - 1)) { |
5028 |
+ |
if (subtasks != null && !inForkJoinPool()) { |
5029 |
+ |
while ((s = a.parent) != null) |
5030 |
+ |
a = s; |
5031 |
+ |
while (!a.isDone()) { |
5032 |
+ |
BulkAction<K,V,?> next = subtasks.nextTask; |
5033 |
+ |
if (subtasks.tryUnfork()) |
5034 |
+ |
subtasks.exec(); |
5035 |
+ |
if ((subtasks = next) == null) |
5036 |
+ |
break; |
5037 |
+ |
} |
5038 |
+ |
} |
5039 |
+ |
break; |
5040 |
+ |
} |
5041 |
+ |
} |
5042 |
+ |
} |
5043 |
+ |
|
5044 |
+ |
} |
5045 |
+ |
|
5046 |
|
/* |
5047 |
|
* Task classes. Coded in a regular but ugly format/style to |
5048 |
|
* simplify checks that each variant differs in the right way from |
5050 |
|
*/ |
5051 |
|
|
5052 |
|
@SuppressWarnings("serial") static final class ForEachKeyTask<K,V> |
5053 |
< |
extends BulkTask<K,V,Void> { |
5053 |
> |
extends BulkAction<K,V,Void> { |
5054 |
|
final Action<K> action; |
5055 |
|
ForEachKeyTask |
5056 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5057 |
+ |
ForEachKeyTask<K,V> nextTask, |
5058 |
|
Action<K> action) { |
5059 |
< |
super(m, p, b); |
5059 |
> |
super(m, p, b, nextTask); |
5060 |
|
this.action = action; |
5061 |
|
} |
5062 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5063 |
|
final Action<K> action = this.action; |
5064 |
|
if (action == null) |
5065 |
|
return abortOnNullFunction(); |
5066 |
+ |
ForEachKeyTask<K,V> subtasks = null; |
5067 |
|
try { |
5068 |
|
int b = batch(), c; |
5069 |
|
while (b > 1 && baseIndex != baseLimit) { |
5070 |
|
do {} while (!casPending(c = pending, c+1)); |
5071 |
< |
new ForEachKeyTask<K,V>(map, this, b >>>= 1, action).fork(); |
5071 |
> |
(subtasks = new ForEachKeyTask<K,V> |
5072 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5073 |
|
} |
5074 |
|
while (advance() != null) |
5075 |
|
action.apply((K)nextKey); |
4989 |
– |
tryComplete(); |
5076 |
|
} catch (Throwable ex) { |
5077 |
|
return tryCompleteComputation(ex); |
5078 |
|
} |
5079 |
+ |
tryComplete(subtasks); |
5080 |
|
return false; |
5081 |
|
} |
5082 |
|
} |
5083 |
|
|
5084 |
|
@SuppressWarnings("serial") static final class ForEachValueTask<K,V> |
5085 |
< |
extends BulkTask<K,V,Void> { |
5085 |
> |
extends BulkAction<K,V,Void> { |
5086 |
|
final Action<V> action; |
5087 |
|
ForEachValueTask |
5088 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5089 |
+ |
ForEachValueTask<K,V> nextTask, |
5090 |
|
Action<V> action) { |
5091 |
< |
super(m, p, b); |
5091 |
> |
super(m, p, b, nextTask); |
5092 |
|
this.action = action; |
5093 |
|
} |
5094 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5095 |
|
final Action<V> action = this.action; |
5096 |
|
if (action == null) |
5097 |
|
return abortOnNullFunction(); |
5098 |
+ |
ForEachValueTask<K,V> subtasks = null; |
5099 |
|
try { |
5100 |
|
int b = batch(), c; |
5101 |
|
while (b > 1 && baseIndex != baseLimit) { |
5102 |
|
do {} while (!casPending(c = pending, c+1)); |
5103 |
< |
new ForEachValueTask<K,V>(map, this, b >>>= 1, action).fork(); |
5103 |
> |
(subtasks = new ForEachValueTask<K,V> |
5104 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5105 |
|
} |
5106 |
|
Object v; |
5107 |
|
while ((v = advance()) != null) |
5108 |
|
action.apply((V)v); |
5019 |
– |
tryComplete(); |
5109 |
|
} catch (Throwable ex) { |
5110 |
|
return tryCompleteComputation(ex); |
5111 |
|
} |
5112 |
+ |
tryComplete(subtasks); |
5113 |
|
return false; |
5114 |
|
} |
5115 |
|
} |
5116 |
|
|
5117 |
|
@SuppressWarnings("serial") static final class ForEachEntryTask<K,V> |
5118 |
< |
extends BulkTask<K,V,Void> { |
5118 |
> |
extends BulkAction<K,V,Void> { |
5119 |
|
final Action<Entry<K,V>> action; |
5120 |
|
ForEachEntryTask |
5121 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5122 |
+ |
ForEachEntryTask<K,V> nextTask, |
5123 |
|
Action<Entry<K,V>> action) { |
5124 |
< |
super(m, p, b); |
5124 |
> |
super(m, p, b, nextTask); |
5125 |
|
this.action = action; |
5126 |
|
} |
5127 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5128 |
|
final Action<Entry<K,V>> action = this.action; |
5129 |
|
if (action == null) |
5130 |
|
return abortOnNullFunction(); |
5131 |
+ |
ForEachEntryTask<K,V> subtasks = null; |
5132 |
|
try { |
5133 |
|
int b = batch(), c; |
5134 |
|
while (b > 1 && baseIndex != baseLimit) { |
5135 |
|
do {} while (!casPending(c = pending, c+1)); |
5136 |
< |
new ForEachEntryTask<K,V>(map, this, b >>>= 1, action).fork(); |
5136 |
> |
(subtasks = new ForEachEntryTask<K,V> |
5137 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5138 |
|
} |
5139 |
|
Object v; |
5140 |
|
while ((v = advance()) != null) |
5141 |
|
action.apply(entryFor((K)nextKey, (V)v)); |
5049 |
– |
tryComplete(); |
5142 |
|
} catch (Throwable ex) { |
5143 |
|
return tryCompleteComputation(ex); |
5144 |
|
} |
5145 |
+ |
tryComplete(subtasks); |
5146 |
|
return false; |
5147 |
|
} |
5148 |
|
} |
5149 |
|
|
5150 |
|
@SuppressWarnings("serial") static final class ForEachMappingTask<K,V> |
5151 |
< |
extends BulkTask<K,V,Void> { |
5151 |
> |
extends BulkAction<K,V,Void> { |
5152 |
|
final BiAction<K,V> action; |
5153 |
|
ForEachMappingTask |
5154 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5155 |
+ |
ForEachMappingTask<K,V> nextTask, |
5156 |
|
BiAction<K,V> action) { |
5157 |
< |
super(m, p, b); |
5157 |
> |
super(m, p, b, nextTask); |
5158 |
|
this.action = action; |
5159 |
|
} |
5160 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5161 |
|
final BiAction<K,V> action = this.action; |
5162 |
|
if (action == null) |
5163 |
|
return abortOnNullFunction(); |
5164 |
+ |
ForEachMappingTask<K,V> subtasks = null; |
5165 |
|
try { |
5166 |
|
int b = batch(), c; |
5167 |
|
while (b > 1 && baseIndex != baseLimit) { |
5168 |
|
do {} while (!casPending(c = pending, c+1)); |
5169 |
< |
new ForEachMappingTask<K,V>(map, this, b >>>= 1, |
5170 |
< |
action).fork(); |
5169 |
> |
(subtasks = new ForEachMappingTask<K,V> |
5170 |
> |
(map, this, b >>>= 1, subtasks, action)).fork(); |
5171 |
|
} |
5172 |
|
Object v; |
5173 |
|
while ((v = advance()) != null) |
5174 |
|
action.apply((K)nextKey, (V)v); |
5080 |
– |
tryComplete(); |
5175 |
|
} catch (Throwable ex) { |
5176 |
|
return tryCompleteComputation(ex); |
5177 |
|
} |
5178 |
+ |
tryComplete(subtasks); |
5179 |
|
return false; |
5180 |
|
} |
5181 |
|
} |
5182 |
|
|
5183 |
|
@SuppressWarnings("serial") static final class ForEachTransformedKeyTask<K,V,U> |
5184 |
< |
extends BulkTask<K,V,Void> { |
5184 |
> |
extends BulkAction<K,V,Void> { |
5185 |
|
final Fun<? super K, ? extends U> transformer; |
5186 |
|
final Action<U> action; |
5187 |
|
ForEachTransformedKeyTask |
5188 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5189 |
+ |
ForEachTransformedKeyTask<K,V,U> nextTask, |
5190 |
|
Fun<? super K, ? extends U> transformer, |
5191 |
|
Action<U> action) { |
5192 |
< |
super(m, p, b); |
5192 |
> |
super(m, p, b, nextTask); |
5193 |
|
this.transformer = transformer; |
5194 |
|
this.action = action; |
5195 |
|
|
5200 |
|
final Action<U> action = this.action; |
5201 |
|
if (transformer == null || action == null) |
5202 |
|
return abortOnNullFunction(); |
5203 |
+ |
ForEachTransformedKeyTask<K,V,U> subtasks = null; |
5204 |
|
try { |
5205 |
|
int b = batch(), c; |
5206 |
|
while (b > 1 && baseIndex != baseLimit) { |
5207 |
|
do {} while (!casPending(c = pending, c+1)); |
5208 |
< |
new ForEachTransformedKeyTask<K,V,U> |
5209 |
< |
(map, this, b >>>= 1, transformer, action).fork(); |
5208 |
> |
(subtasks = new ForEachTransformedKeyTask<K,V,U> |
5209 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5210 |
|
} |
5211 |
|
U u; |
5212 |
|
while (advance() != null) { |
5213 |
|
if ((u = transformer.apply((K)nextKey)) != null) |
5214 |
|
action.apply(u); |
5215 |
|
} |
5119 |
– |
tryComplete(); |
5216 |
|
} catch (Throwable ex) { |
5217 |
|
return tryCompleteComputation(ex); |
5218 |
|
} |
5219 |
+ |
tryComplete(subtasks); |
5220 |
|
return false; |
5221 |
|
} |
5222 |
|
} |
5223 |
|
|
5224 |
|
@SuppressWarnings("serial") static final class ForEachTransformedValueTask<K,V,U> |
5225 |
< |
extends BulkTask<K,V,Void> { |
5225 |
> |
extends BulkAction<K,V,Void> { |
5226 |
|
final Fun<? super V, ? extends U> transformer; |
5227 |
|
final Action<U> action; |
5228 |
|
ForEachTransformedValueTask |
5229 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5230 |
+ |
ForEachTransformedValueTask<K,V,U> nextTask, |
5231 |
|
Fun<? super V, ? extends U> transformer, |
5232 |
|
Action<U> action) { |
5233 |
< |
super(m, p, b); |
5233 |
> |
super(m, p, b, nextTask); |
5234 |
|
this.transformer = transformer; |
5235 |
|
this.action = action; |
5236 |
|
|
5241 |
|
final Action<U> action = this.action; |
5242 |
|
if (transformer == null || action == null) |
5243 |
|
return abortOnNullFunction(); |
5244 |
+ |
ForEachTransformedValueTask<K,V,U> subtasks = null; |
5245 |
|
try { |
5246 |
|
int b = batch(), c; |
5247 |
|
while (b > 1 && baseIndex != baseLimit) { |
5248 |
|
do {} while (!casPending(c = pending, c+1)); |
5249 |
< |
new ForEachTransformedValueTask<K,V,U> |
5250 |
< |
(map, this, b >>>= 1, transformer, action).fork(); |
5249 |
> |
(subtasks = new ForEachTransformedValueTask<K,V,U> |
5250 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5251 |
|
} |
5252 |
|
Object v; U u; |
5253 |
|
while ((v = advance()) != null) { |
5254 |
|
if ((u = transformer.apply((V)v)) != null) |
5255 |
|
action.apply(u); |
5256 |
|
} |
5158 |
– |
tryComplete(); |
5257 |
|
} catch (Throwable ex) { |
5258 |
|
return tryCompleteComputation(ex); |
5259 |
|
} |
5260 |
+ |
tryComplete(subtasks); |
5261 |
|
return false; |
5262 |
|
} |
5263 |
|
} |
5264 |
|
|
5265 |
|
@SuppressWarnings("serial") static final class ForEachTransformedEntryTask<K,V,U> |
5266 |
< |
extends BulkTask<K,V,Void> { |
5266 |
> |
extends BulkAction<K,V,Void> { |
5267 |
|
final Fun<Map.Entry<K,V>, ? extends U> transformer; |
5268 |
|
final Action<U> action; |
5269 |
|
ForEachTransformedEntryTask |
5270 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5271 |
+ |
ForEachTransformedEntryTask<K,V,U> nextTask, |
5272 |
|
Fun<Map.Entry<K,V>, ? extends U> transformer, |
5273 |
|
Action<U> action) { |
5274 |
< |
super(m, p, b); |
5274 |
> |
super(m, p, b, nextTask); |
5275 |
|
this.transformer = transformer; |
5276 |
|
this.action = action; |
5277 |
|
|
5282 |
|
final Action<U> action = this.action; |
5283 |
|
if (transformer == null || action == null) |
5284 |
|
return abortOnNullFunction(); |
5285 |
+ |
ForEachTransformedEntryTask<K,V,U> subtasks = null; |
5286 |
|
try { |
5287 |
|
int b = batch(), c; |
5288 |
|
while (b > 1 && baseIndex != baseLimit) { |
5289 |
|
do {} while (!casPending(c = pending, c+1)); |
5290 |
< |
new ForEachTransformedEntryTask<K,V,U> |
5291 |
< |
(map, this, b >>>= 1, transformer, action).fork(); |
5290 |
> |
(subtasks = new ForEachTransformedEntryTask<K,V,U> |
5291 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5292 |
|
} |
5293 |
|
Object v; U u; |
5294 |
|
while ((v = advance()) != null) { |
5295 |
|
if ((u = transformer.apply(entryFor((K)nextKey, (V)v))) != null) |
5296 |
|
action.apply(u); |
5297 |
|
} |
5197 |
– |
tryComplete(); |
5298 |
|
} catch (Throwable ex) { |
5299 |
|
return tryCompleteComputation(ex); |
5300 |
|
} |
5301 |
+ |
tryComplete(subtasks); |
5302 |
|
return false; |
5303 |
|
} |
5304 |
|
} |
5305 |
|
|
5306 |
|
@SuppressWarnings("serial") static final class ForEachTransformedMappingTask<K,V,U> |
5307 |
< |
extends BulkTask<K,V,Void> { |
5307 |
> |
extends BulkAction<K,V,Void> { |
5308 |
|
final BiFun<? super K, ? super V, ? extends U> transformer; |
5309 |
|
final Action<U> action; |
5310 |
|
ForEachTransformedMappingTask |
5311 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5312 |
+ |
ForEachTransformedMappingTask<K,V,U> nextTask, |
5313 |
|
BiFun<? super K, ? super V, ? extends U> transformer, |
5314 |
|
Action<U> action) { |
5315 |
< |
super(m, p, b); |
5315 |
> |
super(m, p, b, nextTask); |
5316 |
|
this.transformer = transformer; |
5317 |
|
this.action = action; |
5318 |
|
|
5323 |
|
final Action<U> action = this.action; |
5324 |
|
if (transformer == null || action == null) |
5325 |
|
return abortOnNullFunction(); |
5326 |
+ |
ForEachTransformedMappingTask<K,V,U> subtasks = null; |
5327 |
|
try { |
5328 |
|
int b = batch(), c; |
5329 |
|
while (b > 1 && baseIndex != baseLimit) { |
5330 |
|
do {} while (!casPending(c = pending, c+1)); |
5331 |
< |
new ForEachTransformedMappingTask<K,V,U> |
5332 |
< |
(map, this, b >>>= 1, transformer, action).fork(); |
5331 |
> |
(subtasks = new ForEachTransformedMappingTask<K,V,U> |
5332 |
> |
(map, this, b >>>= 1, subtasks, transformer, action)).fork(); |
5333 |
|
} |
5334 |
|
Object v; U u; |
5335 |
|
while ((v = advance()) != null) { |
5336 |
|
if ((u = transformer.apply((K)nextKey, (V)v)) != null) |
5337 |
|
action.apply(u); |
5338 |
|
} |
5236 |
– |
tryComplete(); |
5339 |
|
} catch (Throwable ex) { |
5340 |
|
return tryCompleteComputation(ex); |
5341 |
|
} |
5342 |
+ |
tryComplete(subtasks); |
5343 |
|
return false; |
5344 |
|
} |
5345 |
|
} |
5346 |
|
|
5347 |
|
@SuppressWarnings("serial") static final class SearchKeysTask<K,V,U> |
5348 |
< |
extends BulkTask<K,V,U> { |
5348 |
> |
extends BulkAction<K,V,U> { |
5349 |
|
final Fun<? super K, ? extends U> searchFunction; |
5350 |
|
final AtomicReference<U> result; |
5351 |
|
SearchKeysTask |
5352 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5353 |
+ |
SearchKeysTask<K,V,U> nextTask, |
5354 |
|
Fun<? super K, ? extends U> searchFunction, |
5355 |
|
AtomicReference<U> result) { |
5356 |
< |
super(m, p, b); |
5356 |
> |
super(m, p, b, nextTask); |
5357 |
|
this.searchFunction = searchFunction; this.result = result; |
5358 |
|
} |
5359 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5362 |
|
this.searchFunction; |
5363 |
|
if (searchFunction == null || result == null) |
5364 |
|
return abortOnNullFunction(); |
5365 |
+ |
SearchKeysTask<K,V,U> subtasks = null; |
5366 |
|
try { |
5367 |
|
int b = batch(), c; |
5368 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5369 |
|
do {} while (!casPending(c = pending, c+1)); |
5370 |
< |
new SearchKeysTask<K,V,U>(map, this, b >>>= 1, |
5371 |
< |
searchFunction, result).fork(); |
5370 |
> |
(subtasks = new SearchKeysTask<K,V,U> |
5371 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5372 |
|
} |
5373 |
|
U u; |
5374 |
|
while (result.get() == null && advance() != null) { |
5378 |
|
break; |
5379 |
|
} |
5380 |
|
} |
5276 |
– |
tryComplete(); |
5381 |
|
} catch (Throwable ex) { |
5382 |
|
return tryCompleteComputation(ex); |
5383 |
|
} |
5384 |
+ |
tryComplete(subtasks); |
5385 |
|
return false; |
5386 |
|
} |
5387 |
|
public final U getRawResult() { return result.get(); } |
5388 |
|
} |
5389 |
|
|
5390 |
|
@SuppressWarnings("serial") static final class SearchValuesTask<K,V,U> |
5391 |
< |
extends BulkTask<K,V,U> { |
5391 |
> |
extends BulkAction<K,V,U> { |
5392 |
|
final Fun<? super V, ? extends U> searchFunction; |
5393 |
|
final AtomicReference<U> result; |
5394 |
|
SearchValuesTask |
5395 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5396 |
+ |
SearchValuesTask<K,V,U> nextTask, |
5397 |
|
Fun<? super V, ? extends U> searchFunction, |
5398 |
|
AtomicReference<U> result) { |
5399 |
< |
super(m, p, b); |
5399 |
> |
super(m, p, b, nextTask); |
5400 |
|
this.searchFunction = searchFunction; this.result = result; |
5401 |
|
} |
5402 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5405 |
|
this.searchFunction; |
5406 |
|
if (searchFunction == null || result == null) |
5407 |
|
return abortOnNullFunction(); |
5408 |
+ |
SearchValuesTask<K,V,U> subtasks = null; |
5409 |
|
try { |
5410 |
|
int b = batch(), c; |
5411 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5412 |
|
do {} while (!casPending(c = pending, c+1)); |
5413 |
< |
new SearchValuesTask<K,V,U>(map, this, b >>>= 1, |
5414 |
< |
searchFunction, result).fork(); |
5413 |
> |
(subtasks = new SearchValuesTask<K,V,U> |
5414 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5415 |
|
} |
5416 |
|
Object v; U u; |
5417 |
|
while (result.get() == null && (v = advance()) != null) { |
5421 |
|
break; |
5422 |
|
} |
5423 |
|
} |
5317 |
– |
tryComplete(); |
5424 |
|
} catch (Throwable ex) { |
5425 |
|
return tryCompleteComputation(ex); |
5426 |
|
} |
5427 |
+ |
tryComplete(subtasks); |
5428 |
|
return false; |
5429 |
|
} |
5430 |
|
public final U getRawResult() { return result.get(); } |
5431 |
|
} |
5432 |
|
|
5433 |
|
@SuppressWarnings("serial") static final class SearchEntriesTask<K,V,U> |
5434 |
< |
extends BulkTask<K,V,U> { |
5434 |
> |
extends BulkAction<K,V,U> { |
5435 |
|
final Fun<Entry<K,V>, ? extends U> searchFunction; |
5436 |
|
final AtomicReference<U> result; |
5437 |
|
SearchEntriesTask |
5438 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5439 |
+ |
SearchEntriesTask<K,V,U> nextTask, |
5440 |
|
Fun<Entry<K,V>, ? extends U> searchFunction, |
5441 |
|
AtomicReference<U> result) { |
5442 |
< |
super(m, p, b); |
5442 |
> |
super(m, p, b, nextTask); |
5443 |
|
this.searchFunction = searchFunction; this.result = result; |
5444 |
|
} |
5445 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5448 |
|
this.searchFunction; |
5449 |
|
if (searchFunction == null || result == null) |
5450 |
|
return abortOnNullFunction(); |
5451 |
+ |
SearchEntriesTask<K,V,U> subtasks = null; |
5452 |
|
try { |
5453 |
|
int b = batch(), c; |
5454 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5455 |
|
do {} while (!casPending(c = pending, c+1)); |
5456 |
< |
new SearchEntriesTask<K,V,U>(map, this, b >>>= 1, |
5457 |
< |
searchFunction, result).fork(); |
5456 |
> |
(subtasks = new SearchEntriesTask<K,V,U> |
5457 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5458 |
|
} |
5459 |
|
Object v; U u; |
5460 |
|
while (result.get() == null && (v = advance()) != null) { |
5464 |
|
break; |
5465 |
|
} |
5466 |
|
} |
5358 |
– |
tryComplete(); |
5467 |
|
} catch (Throwable ex) { |
5468 |
|
return tryCompleteComputation(ex); |
5469 |
|
} |
5470 |
+ |
tryComplete(subtasks); |
5471 |
|
return false; |
5472 |
|
} |
5473 |
|
public final U getRawResult() { return result.get(); } |
5474 |
|
} |
5475 |
|
|
5476 |
|
@SuppressWarnings("serial") static final class SearchMappingsTask<K,V,U> |
5477 |
< |
extends BulkTask<K,V,U> { |
5477 |
> |
extends BulkAction<K,V,U> { |
5478 |
|
final BiFun<? super K, ? super V, ? extends U> searchFunction; |
5479 |
|
final AtomicReference<U> result; |
5480 |
|
SearchMappingsTask |
5481 |
|
(ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b, |
5482 |
+ |
SearchMappingsTask<K,V,U> nextTask, |
5483 |
|
BiFun<? super K, ? super V, ? extends U> searchFunction, |
5484 |
|
AtomicReference<U> result) { |
5485 |
< |
super(m, p, b); |
5485 |
> |
super(m, p, b, nextTask); |
5486 |
|
this.searchFunction = searchFunction; this.result = result; |
5487 |
|
} |
5488 |
|
@SuppressWarnings("unchecked") public final boolean exec() { |
5491 |
|
this.searchFunction; |
5492 |
|
if (searchFunction == null || result == null) |
5493 |
|
return abortOnNullFunction(); |
5494 |
+ |
SearchMappingsTask<K,V,U> subtasks = null; |
5495 |
|
try { |
5496 |
|
int b = batch(), c; |
5497 |
|
while (b > 1 && baseIndex != baseLimit && result.get() == null) { |
5498 |
|
do {} while (!casPending(c = pending, c+1)); |
5499 |
< |
new SearchMappingsTask<K,V,U>(map, this, b >>>= 1, |
5500 |
< |
searchFunction, result).fork(); |
5499 |
> |
(subtasks = new SearchMappingsTask<K,V,U> |
5500 |
> |
(map, this, b >>>= 1, subtasks, searchFunction, result)).fork(); |
5501 |
|
} |
5502 |
|
Object v; U u; |
5503 |
|
while (result.get() == null && (v = advance()) != null) { |
5507 |
|
break; |
5508 |
|
} |
5509 |
|
} |
5399 |
– |
tryComplete(); |
5510 |
|
} catch (Throwable ex) { |
5511 |
|
return tryCompleteComputation(ex); |
5512 |
|
} |
5513 |
+ |
tryComplete(subtasks); |
5514 |
|
return false; |
5515 |
|
} |
5516 |
|
public final U getRawResult() { return result.get(); } |
5565 |
|
} catch (Throwable ex) { |
5566 |
|
return tryCompleteComputation(ex); |
5567 |
|
} |
5568 |
+ |
ReduceKeysTask<K,V> s = rights; |
5569 |
+ |
if (s != null && !inForkJoinPool()) { |
5570 |
+ |
do { |
5571 |
+ |
if (s.tryUnfork()) |
5572 |
+ |
s.exec(); |
5573 |
+ |
} while ((s = s.nextRight) != null); |
5574 |
+ |
} |
5575 |
|
return false; |
5576 |
|
} |
5577 |
|
public final K getRawResult() { return result; } |
5627 |
|
} catch (Throwable ex) { |
5628 |
|
return tryCompleteComputation(ex); |
5629 |
|
} |
5630 |
+ |
ReduceValuesTask<K,V> s = rights; |
5631 |
+ |
if (s != null && !inForkJoinPool()) { |
5632 |
+ |
do { |
5633 |
+ |
if (s.tryUnfork()) |
5634 |
+ |
s.exec(); |
5635 |
+ |
} while ((s = s.nextRight) != null); |
5636 |
+ |
} |
5637 |
|
return false; |
5638 |
|
} |
5639 |
|
public final V getRawResult() { return result; } |
5689 |
|
} catch (Throwable ex) { |
5690 |
|
return tryCompleteComputation(ex); |
5691 |
|
} |
5692 |
+ |
ReduceEntriesTask<K,V> s = rights; |
5693 |
+ |
if (s != null && !inForkJoinPool()) { |
5694 |
+ |
do { |
5695 |
+ |
if (s.tryUnfork()) |
5696 |
+ |
s.exec(); |
5697 |
+ |
} while ((s = s.nextRight) != null); |
5698 |
+ |
} |
5699 |
|
return false; |
5700 |
|
} |
5701 |
|
public final Map.Entry<K,V> getRawResult() { return result; } |
5755 |
|
} catch (Throwable ex) { |
5756 |
|
return tryCompleteComputation(ex); |
5757 |
|
} |
5758 |
+ |
MapReduceKeysTask<K,V,U> s = rights; |
5759 |
+ |
if (s != null && !inForkJoinPool()) { |
5760 |
+ |
do { |
5761 |
+ |
if (s.tryUnfork()) |
5762 |
+ |
s.exec(); |
5763 |
+ |
} while ((s = s.nextRight) != null); |
5764 |
+ |
} |
5765 |
|
return false; |
5766 |
|
} |
5767 |
|
public final U getRawResult() { return result; } |
5822 |
|
} catch (Throwable ex) { |
5823 |
|
return tryCompleteComputation(ex); |
5824 |
|
} |
5825 |
+ |
MapReduceValuesTask<K,V,U> s = rights; |
5826 |
+ |
if (s != null && !inForkJoinPool()) { |
5827 |
+ |
do { |
5828 |
+ |
if (s.tryUnfork()) |
5829 |
+ |
s.exec(); |
5830 |
+ |
} while ((s = s.nextRight) != null); |
5831 |
+ |
} |
5832 |
|
return false; |
5833 |
|
} |
5834 |
|
public final U getRawResult() { return result; } |
5889 |
|
} catch (Throwable ex) { |
5890 |
|
return tryCompleteComputation(ex); |
5891 |
|
} |
5892 |
+ |
MapReduceEntriesTask<K,V,U> s = rights; |
5893 |
+ |
if (s != null && !inForkJoinPool()) { |
5894 |
+ |
do { |
5895 |
+ |
if (s.tryUnfork()) |
5896 |
+ |
s.exec(); |
5897 |
+ |
} while ((s = s.nextRight) != null); |
5898 |
+ |
} |
5899 |
|
return false; |
5900 |
|
} |
5901 |
|
public final U getRawResult() { return result; } |
5956 |
|
} catch (Throwable ex) { |
5957 |
|
return tryCompleteComputation(ex); |
5958 |
|
} |
5959 |
+ |
MapReduceMappingsTask<K,V,U> s = rights; |
5960 |
+ |
if (s != null && !inForkJoinPool()) { |
5961 |
+ |
do { |
5962 |
+ |
if (s.tryUnfork()) |
5963 |
+ |
s.exec(); |
5964 |
+ |
} while ((s = s.nextRight) != null); |
5965 |
+ |
} |
5966 |
|
return false; |
5967 |
|
} |
5968 |
|
public final U getRawResult() { return result; } |
6021 |
|
} catch (Throwable ex) { |
6022 |
|
return tryCompleteComputation(ex); |
6023 |
|
} |
6024 |
+ |
MapReduceKeysToDoubleTask<K,V> s = rights; |
6025 |
+ |
if (s != null && !inForkJoinPool()) { |
6026 |
+ |
do { |
6027 |
+ |
if (s.tryUnfork()) |
6028 |
+ |
s.exec(); |
6029 |
+ |
} while ((s = s.nextRight) != null); |
6030 |
+ |
} |
6031 |
|
return false; |
6032 |
|
} |
6033 |
|
public final Double getRawResult() { return result; } |
6087 |
|
} catch (Throwable ex) { |
6088 |
|
return tryCompleteComputation(ex); |
6089 |
|
} |
6090 |
+ |
MapReduceValuesToDoubleTask<K,V> s = rights; |
6091 |
+ |
if (s != null && !inForkJoinPool()) { |
6092 |
+ |
do { |
6093 |
+ |
if (s.tryUnfork()) |
6094 |
+ |
s.exec(); |
6095 |
+ |
} while ((s = s.nextRight) != null); |
6096 |
+ |
} |
6097 |
|
return false; |
6098 |
|
} |
6099 |
|
public final Double getRawResult() { return result; } |
6153 |
|
} catch (Throwable ex) { |
6154 |
|
return tryCompleteComputation(ex); |
6155 |
|
} |
6156 |
+ |
MapReduceEntriesToDoubleTask<K,V> s = rights; |
6157 |
+ |
if (s != null && !inForkJoinPool()) { |
6158 |
+ |
do { |
6159 |
+ |
if (s.tryUnfork()) |
6160 |
+ |
s.exec(); |
6161 |
+ |
} while ((s = s.nextRight) != null); |
6162 |
+ |
} |
6163 |
|
return false; |
6164 |
|
} |
6165 |
|
public final Double getRawResult() { return result; } |
6219 |
|
} catch (Throwable ex) { |
6220 |
|
return tryCompleteComputation(ex); |
6221 |
|
} |
6222 |
+ |
MapReduceMappingsToDoubleTask<K,V> s = rights; |
6223 |
+ |
if (s != null && !inForkJoinPool()) { |
6224 |
+ |
do { |
6225 |
+ |
if (s.tryUnfork()) |
6226 |
+ |
s.exec(); |
6227 |
+ |
} while ((s = s.nextRight) != null); |
6228 |
+ |
} |
6229 |
|
return false; |
6230 |
|
} |
6231 |
|
public final Double getRawResult() { return result; } |
6284 |
|
} catch (Throwable ex) { |
6285 |
|
return tryCompleteComputation(ex); |
6286 |
|
} |
6287 |
+ |
MapReduceKeysToLongTask<K,V> s = rights; |
6288 |
+ |
if (s != null && !inForkJoinPool()) { |
6289 |
+ |
do { |
6290 |
+ |
if (s.tryUnfork()) |
6291 |
+ |
s.exec(); |
6292 |
+ |
} while ((s = s.nextRight) != null); |
6293 |
+ |
} |
6294 |
|
return false; |
6295 |
|
} |
6296 |
|
public final Long getRawResult() { return result; } |
6350 |
|
} catch (Throwable ex) { |
6351 |
|
return tryCompleteComputation(ex); |
6352 |
|
} |
6353 |
+ |
MapReduceValuesToLongTask<K,V> s = rights; |
6354 |
+ |
if (s != null && !inForkJoinPool()) { |
6355 |
+ |
do { |
6356 |
+ |
if (s.tryUnfork()) |
6357 |
+ |
s.exec(); |
6358 |
+ |
} while ((s = s.nextRight) != null); |
6359 |
+ |
} |
6360 |
|
return false; |
6361 |
|
} |
6362 |
|
public final Long getRawResult() { return result; } |
6416 |
|
} catch (Throwable ex) { |
6417 |
|
return tryCompleteComputation(ex); |
6418 |
|
} |
6419 |
+ |
MapReduceEntriesToLongTask<K,V> s = rights; |
6420 |
+ |
if (s != null && !inForkJoinPool()) { |
6421 |
+ |
do { |
6422 |
+ |
if (s.tryUnfork()) |
6423 |
+ |
s.exec(); |
6424 |
+ |
} while ((s = s.nextRight) != null); |
6425 |
+ |
} |
6426 |
|
return false; |
6427 |
|
} |
6428 |
|
public final Long getRawResult() { return result; } |
6482 |
|
} catch (Throwable ex) { |
6483 |
|
return tryCompleteComputation(ex); |
6484 |
|
} |
6485 |
+ |
MapReduceMappingsToLongTask<K,V> s = rights; |
6486 |
+ |
if (s != null && !inForkJoinPool()) { |
6487 |
+ |
do { |
6488 |
+ |
if (s.tryUnfork()) |
6489 |
+ |
s.exec(); |
6490 |
+ |
} while ((s = s.nextRight) != null); |
6491 |
+ |
} |
6492 |
|
return false; |
6493 |
|
} |
6494 |
|
public final Long getRawResult() { return result; } |
6547 |
|
} catch (Throwable ex) { |
6548 |
|
return tryCompleteComputation(ex); |
6549 |
|
} |
6550 |
+ |
MapReduceKeysToIntTask<K,V> s = rights; |
6551 |
+ |
if (s != null && !inForkJoinPool()) { |
6552 |
+ |
do { |
6553 |
+ |
if (s.tryUnfork()) |
6554 |
+ |
s.exec(); |
6555 |
+ |
} while ((s = s.nextRight) != null); |
6556 |
+ |
} |
6557 |
|
return false; |
6558 |
|
} |
6559 |
|
public final Integer getRawResult() { return result; } |
6613 |
|
} catch (Throwable ex) { |
6614 |
|
return tryCompleteComputation(ex); |
6615 |
|
} |
6616 |
+ |
MapReduceValuesToIntTask<K,V> s = rights; |
6617 |
+ |
if (s != null && !inForkJoinPool()) { |
6618 |
+ |
do { |
6619 |
+ |
if (s.tryUnfork()) |
6620 |
+ |
s.exec(); |
6621 |
+ |
} while ((s = s.nextRight) != null); |
6622 |
+ |
} |
6623 |
|
return false; |
6624 |
|
} |
6625 |
|
public final Integer getRawResult() { return result; } |
6679 |
|
} catch (Throwable ex) { |
6680 |
|
return tryCompleteComputation(ex); |
6681 |
|
} |
6682 |
+ |
MapReduceEntriesToIntTask<K,V> s = rights; |
6683 |
+ |
if (s != null && !inForkJoinPool()) { |
6684 |
+ |
do { |
6685 |
+ |
if (s.tryUnfork()) |
6686 |
+ |
s.exec(); |
6687 |
+ |
} while ((s = s.nextRight) != null); |
6688 |
+ |
} |
6689 |
|
return false; |
6690 |
|
} |
6691 |
|
public final Integer getRawResult() { return result; } |
6745 |
|
} catch (Throwable ex) { |
6746 |
|
return tryCompleteComputation(ex); |
6747 |
|
} |
6748 |
+ |
MapReduceMappingsToIntTask<K,V> s = rights; |
6749 |
+ |
if (s != null && !inForkJoinPool()) { |
6750 |
+ |
do { |
6751 |
+ |
if (s.tryUnfork()) |
6752 |
+ |
s.exec(); |
6753 |
+ |
} while ((s = s.nextRight) != null); |
6754 |
+ |
} |
6755 |
|
return false; |
6756 |
|
} |
6757 |
|
public final Integer getRawResult() { return result; } |