2190 |
|
extends CountedCompleter<R> { |
2191 |
|
final ConcurrentHashMap<K, V> map; |
2192 |
|
Node<V> next; // the next entry to use |
2193 |
< |
Object nextKey; // cached key field of next |
2193 |
> |
K nextKey; // cached key field of next |
2194 |
|
V nextVal; // cached val field of next |
2195 |
|
Node<V>[] tab; // current table; updated if resized |
2196 |
|
int index; // index of bin to use next |
2279 |
|
} // visit upper slots if present |
2280 |
|
index = (i += baseSize) < n ? i : (baseIndex = b + 1); |
2281 |
|
} |
2282 |
< |
nextKey = e.key; |
2282 |
> |
nextKey = (K)e.key; |
2283 |
|
} while ((ev = e.val) == null); // skip deleted or special nodes |
2284 |
|
next = e; |
2285 |
|
return nextVal = ev; |
2286 |
|
} |
2287 |
|
|
2288 |
|
public final void remove() { |
2289 |
< |
Object k = nextKey; |
2289 |
> |
K k = nextKey; |
2290 |
|
if (k == null && (advance() == null || (k = nextKey) == null)) |
2291 |
|
throw new IllegalStateException(); |
2292 |
|
map.internalReplace(k, null, null); |
2881 |
|
V v; |
2882 |
|
if ((v = it.advance()) != null) { |
2883 |
|
for (;;) { |
2884 |
< |
Object k = it.nextKey; |
2884 |
> |
K k = it.nextKey; |
2885 |
|
sb.append(k == this ? "(this Map)" : k); |
2886 |
|
sb.append('='); |
2887 |
|
sb.append(v == this ? "(this Map)" : v); |
2941 |
|
return null; |
2942 |
|
return new KeyIterator<K,V>(map, this); |
2943 |
|
} |
2944 |
< |
@SuppressWarnings("unchecked") public final K next() { |
2944 |
> |
public final K next() { |
2945 |
|
if (nextVal == null && advance() == null) |
2946 |
|
throw new NoSuchElementException(); |
2947 |
< |
Object k = nextKey; |
2947 |
> |
K k = nextKey; |
2948 |
|
nextVal = null; |
2949 |
< |
return (K) k; |
2949 |
> |
return k; |
2950 |
|
} |
2951 |
|
|
2952 |
|
public final K nextElement() { return next(); } |
2956 |
|
public void forEach(Block<? super K> action) { |
2957 |
|
if (action == null) throw new NullPointerException(); |
2958 |
|
while (advance() != null) |
2959 |
< |
action.accept((K)nextKey); |
2959 |
> |
action.accept(nextKey); |
2960 |
|
} |
2961 |
|
|
2962 |
|
public boolean tryAdvance(Block<? super K> block) { |
2963 |
|
if (block == null) throw new NullPointerException(); |
2964 |
|
if (advance() == null) |
2965 |
|
return false; |
2966 |
< |
block.accept((K)nextKey); |
2966 |
> |
block.accept(nextKey); |
2967 |
|
return true; |
2968 |
|
} |
2969 |
|
} |
3024 |
|
return new EntryIterator<K,V>(map, this); |
3025 |
|
} |
3026 |
|
|
3027 |
< |
@SuppressWarnings("unchecked") public final Map.Entry<K,V> next() { |
3027 |
> |
public final Map.Entry<K,V> next() { |
3028 |
|
V v; |
3029 |
|
if ((v = nextVal) == null && (v = advance()) == null) |
3030 |
|
throw new NoSuchElementException(); |
3031 |
< |
Object k = nextKey; |
3031 |
> |
K k = nextKey; |
3032 |
|
nextVal = null; |
3033 |
< |
return new MapEntry<K,V>((K)k, v, map); |
3033 |
> |
return new MapEntry<K,V>(k, v, map); |
3034 |
|
} |
3035 |
|
|
3036 |
|
public Iterator<Map.Entry<K,V>> iterator() { return this; } |
3039 |
|
if (action == null) throw new NullPointerException(); |
3040 |
|
V v; |
3041 |
|
while ((v = advance()) != null) |
3042 |
< |
action.accept(entryFor((K)nextKey, v)); |
3042 |
> |
action.accept(entryFor(nextKey, v)); |
3043 |
|
} |
3044 |
|
|
3045 |
|
public boolean tryAdvance(Block<? super Map.Entry<K,V>> block) { |
3047 |
|
if (block == null) throw new NullPointerException(); |
3048 |
|
if ((v = advance()) == null) |
3049 |
|
return false; |
3050 |
< |
block.accept(entryFor((K)nextKey, v)); |
3050 |
> |
block.accept(entryFor(nextKey, v)); |
3051 |
|
return true; |
3052 |
|
} |
3053 |
|
|
3237 |
|
* |
3238 |
|
* @param action the action |
3239 |
|
*/ |
3240 |
< |
@SuppressWarnings("unchecked") public void forEachSequentially |
3240 |
> |
public void forEachSequentially |
3241 |
|
(BiBlock<? super K, ? super V> action) { |
3242 |
|
if (action == null) throw new NullPointerException(); |
3243 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3244 |
|
V v; |
3245 |
|
while ((v = it.advance()) != null) |
3246 |
< |
action.accept((K)it.nextKey, v); |
3246 |
> |
action.accept(it.nextKey, v); |
3247 |
|
} |
3248 |
|
|
3249 |
|
/** |
3255 |
|
* which case the action is not applied). |
3256 |
|
* @param action the action |
3257 |
|
*/ |
3258 |
< |
@SuppressWarnings("unchecked") public <U> void forEachSequentially |
3258 |
> |
public <U> void forEachSequentially |
3259 |
|
(BiFunction<? super K, ? super V, ? extends U> transformer, |
3260 |
|
Block<? super U> action) { |
3261 |
|
if (transformer == null || action == null) |
3263 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3264 |
|
V v; U u; |
3265 |
|
while ((v = it.advance()) != null) { |
3266 |
< |
if ((u = transformer.apply((K)it.nextKey, v)) != null) |
3266 |
> |
if ((u = transformer.apply(it.nextKey, v)) != null) |
3267 |
|
action.accept(u); |
3268 |
|
} |
3269 |
|
} |
3277 |
|
* @return a non-null result from applying the given search |
3278 |
|
* function on each (key, value), or null if none |
3279 |
|
*/ |
3280 |
< |
@SuppressWarnings("unchecked") public <U> U searchSequentially |
3280 |
> |
public <U> U searchSequentially |
3281 |
|
(BiFunction<? super K, ? super V, ? extends U> searchFunction) { |
3282 |
|
if (searchFunction == null) throw new NullPointerException(); |
3283 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3284 |
|
V v; U u; |
3285 |
|
while ((v = it.advance()) != null) { |
3286 |
< |
if ((u = searchFunction.apply((K)it.nextKey, v)) != null) |
3286 |
> |
if ((u = searchFunction.apply(it.nextKey, v)) != null) |
3287 |
|
return u; |
3288 |
|
} |
3289 |
|
return null; |
3301 |
|
* @return the result of accumulating the given transformation |
3302 |
|
* of all (key, value) pairs |
3303 |
|
*/ |
3304 |
< |
@SuppressWarnings("unchecked") public <U> U reduceSequentially |
3304 |
> |
public <U> U reduceSequentially |
3305 |
|
(BiFunction<? super K, ? super V, ? extends U> transformer, |
3306 |
|
BiFunction<? super U, ? super U, ? extends U> reducer) { |
3307 |
|
if (transformer == null || reducer == null) |
3309 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3310 |
|
U r = null, u; V v; |
3311 |
|
while ((v = it.advance()) != null) { |
3312 |
< |
if ((u = transformer.apply((K)it.nextKey, v)) != null) |
3312 |
> |
if ((u = transformer.apply(it.nextKey, v)) != null) |
3313 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3314 |
|
} |
3315 |
|
return r; |
3327 |
|
* @return the result of accumulating the given transformation |
3328 |
|
* of all (key, value) pairs |
3329 |
|
*/ |
3330 |
< |
@SuppressWarnings("unchecked") public double reduceToDoubleSequentially |
3330 |
> |
public double reduceToDoubleSequentially |
3331 |
|
(DoubleBiFunction<? super K, ? super V> transformer, |
3332 |
|
double basis, |
3333 |
|
DoubleBinaryOperator reducer) { |
3336 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3337 |
|
double r = basis; V v; |
3338 |
|
while ((v = it.advance()) != null) |
3339 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble((K)it.nextKey, v)); |
3339 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(it.nextKey, v)); |
3340 |
|
return r; |
3341 |
|
} |
3342 |
|
|
3352 |
|
* @return the result of accumulating the given transformation |
3353 |
|
* of all (key, value) pairs |
3354 |
|
*/ |
3355 |
< |
@SuppressWarnings("unchecked") public long reduceToLongSequentially |
3355 |
> |
public long reduceToLongSequentially |
3356 |
|
(LongBiFunction<? super K, ? super V> transformer, |
3357 |
|
long basis, |
3358 |
|
LongBinaryOperator reducer) { |
3361 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3362 |
|
long r = basis; V v; |
3363 |
|
while ((v = it.advance()) != null) |
3364 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong((K)it.nextKey, v)); |
3364 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(it.nextKey, v)); |
3365 |
|
return r; |
3366 |
|
} |
3367 |
|
|
3377 |
|
* @return the result of accumulating the given transformation |
3378 |
|
* of all (key, value) pairs |
3379 |
|
*/ |
3380 |
< |
@SuppressWarnings("unchecked") public int reduceToIntSequentially |
3380 |
> |
public int reduceToIntSequentially |
3381 |
|
(IntBiFunction<? super K, ? super V> transformer, |
3382 |
|
int basis, |
3383 |
|
IntBinaryOperator reducer) { |
3386 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3387 |
|
int r = basis; V v; |
3388 |
|
while ((v = it.advance()) != null) |
3389 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt((K)it.nextKey, v)); |
3389 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(it.nextKey, v)); |
3390 |
|
return r; |
3391 |
|
} |
3392 |
|
|
3395 |
|
* |
3396 |
|
* @param action the action |
3397 |
|
*/ |
3398 |
< |
@SuppressWarnings("unchecked") public void forEachKeySequentially |
3398 |
> |
public void forEachKeySequentially |
3399 |
|
(Block<? super K> action) { |
3400 |
|
if (action == null) throw new NullPointerException(); |
3401 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3402 |
|
while (it.advance() != null) |
3403 |
< |
action.accept((K)it.nextKey); |
3403 |
> |
action.accept(it.nextKey); |
3404 |
|
} |
3405 |
|
|
3406 |
|
/** |
3412 |
|
* which case the action is not applied). |
3413 |
|
* @param action the action |
3414 |
|
*/ |
3415 |
< |
@SuppressWarnings("unchecked") public <U> void forEachKeySequentially |
3415 |
> |
public <U> void forEachKeySequentially |
3416 |
|
(Function<? super K, ? extends U> transformer, |
3417 |
|
Block<? super U> action) { |
3418 |
|
if (transformer == null || action == null) |
3420 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3421 |
|
U u; |
3422 |
|
while (it.advance() != null) { |
3423 |
< |
if ((u = transformer.apply((K)it.nextKey)) != null) |
3423 |
> |
if ((u = transformer.apply(it.nextKey)) != null) |
3424 |
|
action.accept(u); |
3425 |
|
} |
3426 |
|
ForkJoinTasks.forEachKey |
3436 |
|
* @return a non-null result from applying the given search |
3437 |
|
* function on each key, or null if none |
3438 |
|
*/ |
3439 |
< |
@SuppressWarnings("unchecked") public <U> U searchKeysSequentially |
3439 |
> |
public <U> U searchKeysSequentially |
3440 |
|
(Function<? super K, ? extends U> searchFunction) { |
3441 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3442 |
|
U u; |
3443 |
|
while (it.advance() != null) { |
3444 |
< |
if ((u = searchFunction.apply((K)it.nextKey)) != null) |
3444 |
> |
if ((u = searchFunction.apply(it.nextKey)) != null) |
3445 |
|
return u; |
3446 |
|
} |
3447 |
|
return null; |
3455 |
|
* @return the result of accumulating all keys using the given |
3456 |
|
* reducer to combine values, or null if none |
3457 |
|
*/ |
3458 |
< |
@SuppressWarnings("unchecked") public K reduceKeysSequentially |
3458 |
> |
public K reduceKeysSequentially |
3459 |
|
(BiFunction<? super K, ? super K, ? extends K> reducer) { |
3460 |
|
if (reducer == null) throw new NullPointerException(); |
3461 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3462 |
|
K r = null; |
3463 |
|
while (it.advance() != null) { |
3464 |
< |
K u = (K)it.nextKey; |
3464 |
> |
K u = it.nextKey; |
3465 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3466 |
|
} |
3467 |
|
return r; |
3479 |
|
* @return the result of accumulating the given transformation |
3480 |
|
* of all keys |
3481 |
|
*/ |
3482 |
< |
@SuppressWarnings("unchecked") public <U> U reduceKeysSequentially |
3482 |
> |
public <U> U reduceKeysSequentially |
3483 |
|
(Function<? super K, ? extends U> transformer, |
3484 |
|
BiFunction<? super U, ? super U, ? extends U> reducer) { |
3485 |
|
if (transformer == null || reducer == null) |
3487 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3488 |
|
U r = null, u; |
3489 |
|
while (it.advance() != null) { |
3490 |
< |
if ((u = transformer.apply((K)it.nextKey)) != null) |
3490 |
> |
if ((u = transformer.apply(it.nextKey)) != null) |
3491 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3492 |
|
} |
3493 |
|
return r; |
3505 |
|
* @return the result of accumulating the given transformation |
3506 |
|
* of all keys |
3507 |
|
*/ |
3508 |
< |
@SuppressWarnings("unchecked") public double reduceKeysToDoubleSequentially |
3508 |
> |
public double reduceKeysToDoubleSequentially |
3509 |
|
(DoubleFunction<? super K> transformer, |
3510 |
|
double basis, |
3511 |
|
DoubleBinaryOperator reducer) { |
3514 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3515 |
|
double r = basis; |
3516 |
|
while (it.advance() != null) |
3517 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble((K)it.nextKey)); |
3517 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(it.nextKey)); |
3518 |
|
return r; |
3519 |
|
} |
3520 |
|
|
3530 |
|
* @return the result of accumulating the given transformation |
3531 |
|
* of all keys |
3532 |
|
*/ |
3533 |
< |
@SuppressWarnings("unchecked") public long reduceKeysToLongSequentially |
3533 |
> |
public long reduceKeysToLongSequentially |
3534 |
|
(LongFunction<? super K> transformer, |
3535 |
|
long basis, |
3536 |
|
LongBinaryOperator reducer) { |
3539 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3540 |
|
long r = basis; |
3541 |
|
while (it.advance() != null) |
3542 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong((K)it.nextKey)); |
3542 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(it.nextKey)); |
3543 |
|
return r; |
3544 |
|
} |
3545 |
|
|
3555 |
|
* @return the result of accumulating the given transformation |
3556 |
|
* of all keys |
3557 |
|
*/ |
3558 |
< |
@SuppressWarnings("unchecked") public int reduceKeysToIntSequentially |
3558 |
> |
public int reduceKeysToIntSequentially |
3559 |
|
(IntFunction<? super K> transformer, |
3560 |
|
int basis, |
3561 |
|
IntBinaryOperator reducer) { |
3564 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3565 |
|
int r = basis; |
3566 |
|
while (it.advance() != null) |
3567 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt((K)it.nextKey)); |
3567 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(it.nextKey)); |
3568 |
|
return r; |
3569 |
|
} |
3570 |
|
|
3746 |
|
* |
3747 |
|
* @param action the action |
3748 |
|
*/ |
3749 |
< |
@SuppressWarnings("unchecked") public void forEachEntrySequentially |
3749 |
> |
public void forEachEntrySequentially |
3750 |
|
(Block<? super Map.Entry<K,V>> action) { |
3751 |
|
if (action == null) throw new NullPointerException(); |
3752 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3753 |
|
V v; |
3754 |
|
while ((v = it.advance()) != null) |
3755 |
< |
action.accept(entryFor((K)it.nextKey, v)); |
3755 |
> |
action.accept(entryFor(it.nextKey, v)); |
3756 |
|
} |
3757 |
|
|
3758 |
|
/** |
3764 |
|
* which case the action is not applied). |
3765 |
|
* @param action the action |
3766 |
|
*/ |
3767 |
< |
@SuppressWarnings("unchecked") public <U> void forEachEntrySequentially |
3767 |
> |
public <U> void forEachEntrySequentially |
3768 |
|
(Function<Map.Entry<K,V>, ? extends U> transformer, |
3769 |
|
Block<? super U> action) { |
3770 |
|
if (transformer == null || action == null) |
3772 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3773 |
|
V v; U u; |
3774 |
|
while ((v = it.advance()) != null) { |
3775 |
< |
if ((u = transformer.apply(entryFor((K)it.nextKey, v))) != null) |
3775 |
> |
if ((u = transformer.apply(entryFor(it.nextKey, v))) != null) |
3776 |
|
action.accept(u); |
3777 |
|
} |
3778 |
|
} |
3786 |
|
* @return a non-null result from applying the given search |
3787 |
|
* function on each entry, or null if none |
3788 |
|
*/ |
3789 |
< |
@SuppressWarnings("unchecked") public <U> U searchEntriesSequentially |
3789 |
> |
public <U> U searchEntriesSequentially |
3790 |
|
(Function<Map.Entry<K,V>, ? extends U> searchFunction) { |
3791 |
|
if (searchFunction == null) throw new NullPointerException(); |
3792 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3793 |
|
V v; U u; |
3794 |
|
while ((v = it.advance()) != null) { |
3795 |
< |
if ((u = searchFunction.apply(entryFor((K)it.nextKey, v))) != null) |
3795 |
> |
if ((u = searchFunction.apply(entryFor(it.nextKey, v))) != null) |
3796 |
|
return u; |
3797 |
|
} |
3798 |
|
return null; |
3805 |
|
* @param reducer a commutative associative combining function |
3806 |
|
* @return the result of accumulating all entries |
3807 |
|
*/ |
3808 |
< |
@SuppressWarnings("unchecked") public Map.Entry<K,V> reduceEntriesSequentially |
3808 |
> |
public Map.Entry<K,V> reduceEntriesSequentially |
3809 |
|
(BiFunction<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) { |
3810 |
|
if (reducer == null) throw new NullPointerException(); |
3811 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3812 |
|
Map.Entry<K,V> r = null; V v; |
3813 |
|
while ((v = it.advance()) != null) { |
3814 |
< |
Map.Entry<K,V> u = entryFor((K)it.nextKey, v); |
3814 |
> |
Map.Entry<K,V> u = entryFor(it.nextKey, v); |
3815 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3816 |
|
} |
3817 |
|
return r; |
3829 |
|
* @return the result of accumulating the given transformation |
3830 |
|
* of all entries |
3831 |
|
*/ |
3832 |
< |
@SuppressWarnings("unchecked") public <U> U reduceEntriesSequentially |
3832 |
> |
public <U> U reduceEntriesSequentially |
3833 |
|
(Function<Map.Entry<K,V>, ? extends U> transformer, |
3834 |
|
BiFunction<? super U, ? super U, ? extends U> reducer) { |
3835 |
|
if (transformer == null || reducer == null) |
3837 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3838 |
|
U r = null, u; V v; |
3839 |
|
while ((v = it.advance()) != null) { |
3840 |
< |
if ((u = transformer.apply(entryFor((K)it.nextKey, v))) != null) |
3840 |
> |
if ((u = transformer.apply(entryFor(it.nextKey, v))) != null) |
3841 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3842 |
|
} |
3843 |
|
return r; |
3855 |
|
* @return the result of accumulating the given transformation |
3856 |
|
* of all entries |
3857 |
|
*/ |
3858 |
< |
@SuppressWarnings("unchecked") public double reduceEntriesToDoubleSequentially |
3858 |
> |
public double reduceEntriesToDoubleSequentially |
3859 |
|
(DoubleFunction<Map.Entry<K,V>> transformer, |
3860 |
|
double basis, |
3861 |
|
DoubleBinaryOperator reducer) { |
3864 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3865 |
|
double r = basis; V v; |
3866 |
|
while ((v = it.advance()) != null) |
3867 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(entryFor((K)it.nextKey, v))); |
3867 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(entryFor(it.nextKey, v))); |
3868 |
|
return r; |
3869 |
|
} |
3870 |
|
|
3880 |
|
* @return the result of accumulating the given transformation |
3881 |
|
* of all entries |
3882 |
|
*/ |
3883 |
< |
@SuppressWarnings("unchecked") public long reduceEntriesToLongSequentially |
3883 |
> |
public long reduceEntriesToLongSequentially |
3884 |
|
(LongFunction<Map.Entry<K,V>> transformer, |
3885 |
|
long basis, |
3886 |
|
LongBinaryOperator reducer) { |
3889 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3890 |
|
long r = basis; V v; |
3891 |
|
while ((v = it.advance()) != null) |
3892 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong(entryFor((K)it.nextKey, v))); |
3892 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(entryFor(it.nextKey, v))); |
3893 |
|
return r; |
3894 |
|
} |
3895 |
|
|
3905 |
|
* @return the result of accumulating the given transformation |
3906 |
|
* of all entries |
3907 |
|
*/ |
3908 |
< |
@SuppressWarnings("unchecked") public int reduceEntriesToIntSequentially |
3908 |
> |
public int reduceEntriesToIntSequentially |
3909 |
|
(IntFunction<Map.Entry<K,V>> transformer, |
3910 |
|
int basis, |
3911 |
|
IntBinaryOperator reducer) { |
3914 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3915 |
|
int r = basis; V v; |
3916 |
|
while ((v = it.advance()) != null) |
3917 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt(entryFor((K)it.nextKey, v))); |
3917 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(entryFor(it.nextKey, v))); |
3918 |
|
return r; |
3919 |
|
} |
3920 |
|
|
5484 |
|
super(m, p, b); |
5485 |
|
this.action = action; |
5486 |
|
} |
5487 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5487 |
> |
public final void compute() { |
5488 |
|
final Block<? super K> action; |
5489 |
|
if ((action = this.action) != null) { |
5490 |
|
for (int b; (b = preSplit()) > 0;) |
5491 |
|
new ForEachKeyTask<K,V>(map, this, b, action).fork(); |
5492 |
|
while (advance() != null) |
5493 |
< |
action.accept((K)nextKey); |
5493 |
> |
action.accept(nextKey); |
5494 |
|
propagateCompletion(); |
5495 |
|
} |
5496 |
|
} |
5505 |
|
super(m, p, b); |
5506 |
|
this.action = action; |
5507 |
|
} |
5508 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5508 |
> |
public final void compute() { |
5509 |
|
final Block<? super V> action; |
5510 |
|
if ((action = this.action) != null) { |
5511 |
|
for (int b; (b = preSplit()) > 0;) |
5527 |
|
super(m, p, b); |
5528 |
|
this.action = action; |
5529 |
|
} |
5530 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5530 |
> |
public final void compute() { |
5531 |
|
final Block<? super Entry<K,V>> action; |
5532 |
|
if ((action = this.action) != null) { |
5533 |
|
for (int b; (b = preSplit()) > 0;) |
5534 |
|
new ForEachEntryTask<K,V>(map, this, b, action).fork(); |
5535 |
|
V v; |
5536 |
|
while ((v = advance()) != null) |
5537 |
< |
action.accept(entryFor((K)nextKey, v)); |
5537 |
> |
action.accept(entryFor(nextKey, v)); |
5538 |
|
propagateCompletion(); |
5539 |
|
} |
5540 |
|
} |
5549 |
|
super(m, p, b); |
5550 |
|
this.action = action; |
5551 |
|
} |
5552 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5552 |
> |
public final void compute() { |
5553 |
|
final BiBlock<? super K, ? super V> action; |
5554 |
|
if ((action = this.action) != null) { |
5555 |
|
for (int b; (b = preSplit()) > 0;) |
5556 |
|
new ForEachMappingTask<K,V>(map, this, b, action).fork(); |
5557 |
|
V v; |
5558 |
|
while ((v = advance()) != null) |
5559 |
< |
action.accept((K)nextKey, v); |
5559 |
> |
action.accept(nextKey, v); |
5560 |
|
propagateCompletion(); |
5561 |
|
} |
5562 |
|
} |
5572 |
|
super(m, p, b); |
5573 |
|
this.transformer = transformer; this.action = action; |
5574 |
|
} |
5575 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5575 |
> |
public final void compute() { |
5576 |
|
final Function<? super K, ? extends U> transformer; |
5577 |
|
final Block<? super U> action; |
5578 |
|
if ((transformer = this.transformer) != null && |
5582 |
|
(map, this, b, transformer, action).fork(); |
5583 |
|
U u; |
5584 |
|
while (advance() != null) { |
5585 |
< |
if ((u = transformer.apply((K)nextKey)) != null) |
5585 |
> |
if ((u = transformer.apply(nextKey)) != null) |
5586 |
|
action.accept(u); |
5587 |
|
} |
5588 |
|
propagateCompletion(); |
5600 |
|
super(m, p, b); |
5601 |
|
this.transformer = transformer; this.action = action; |
5602 |
|
} |
5603 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5603 |
> |
public final void compute() { |
5604 |
|
final Function<? super V, ? extends U> transformer; |
5605 |
|
final Block<? super U> action; |
5606 |
|
if ((transformer = this.transformer) != null && |
5628 |
|
super(m, p, b); |
5629 |
|
this.transformer = transformer; this.action = action; |
5630 |
|
} |
5631 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5631 |
> |
public final void compute() { |
5632 |
|
final Function<Map.Entry<K,V>, ? extends U> transformer; |
5633 |
|
final Block<? super U> action; |
5634 |
|
if ((transformer = this.transformer) != null && |
5638 |
|
(map, this, b, transformer, action).fork(); |
5639 |
|
V v; U u; |
5640 |
|
while ((v = advance()) != null) { |
5641 |
< |
if ((u = transformer.apply(entryFor((K)nextKey, |
5641 |
> |
if ((u = transformer.apply(entryFor(nextKey, |
5642 |
|
v))) != null) |
5643 |
|
action.accept(u); |
5644 |
|
} |
5658 |
|
super(m, p, b); |
5659 |
|
this.transformer = transformer; this.action = action; |
5660 |
|
} |
5661 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5661 |
> |
public final void compute() { |
5662 |
|
final BiFunction<? super K, ? super V, ? extends U> transformer; |
5663 |
|
final Block<? super U> action; |
5664 |
|
if ((transformer = this.transformer) != null && |
5668 |
|
(map, this, b, transformer, action).fork(); |
5669 |
|
V v; U u; |
5670 |
|
while ((v = advance()) != null) { |
5671 |
< |
if ((u = transformer.apply((K)nextKey, v)) != null) |
5671 |
> |
if ((u = transformer.apply(nextKey, v)) != null) |
5672 |
|
action.accept(u); |
5673 |
|
} |
5674 |
|
propagateCompletion(); |
5688 |
|
this.searchFunction = searchFunction; this.result = result; |
5689 |
|
} |
5690 |
|
public final U getRawResult() { return result.get(); } |
5691 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5691 |
> |
public final void compute() { |
5692 |
|
final Function<? super K, ? extends U> searchFunction; |
5693 |
|
final AtomicReference<U> result; |
5694 |
|
if ((searchFunction = this.searchFunction) != null && |
5707 |
|
propagateCompletion(); |
5708 |
|
break; |
5709 |
|
} |
5710 |
< |
if ((u = searchFunction.apply((K)nextKey)) != null) { |
5710 |
> |
if ((u = searchFunction.apply(nextKey)) != null) { |
5711 |
|
if (result.compareAndSet(null, u)) |
5712 |
|
quietlyCompleteRoot(); |
5713 |
|
break; |
5729 |
|
this.searchFunction = searchFunction; this.result = result; |
5730 |
|
} |
5731 |
|
public final U getRawResult() { return result.get(); } |
5732 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5732 |
> |
public final void compute() { |
5733 |
|
final Function<? super V, ? extends U> searchFunction; |
5734 |
|
final AtomicReference<U> result; |
5735 |
|
if ((searchFunction = this.searchFunction) != null && |
5770 |
|
this.searchFunction = searchFunction; this.result = result; |
5771 |
|
} |
5772 |
|
public final U getRawResult() { return result.get(); } |
5773 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5773 |
> |
public final void compute() { |
5774 |
|
final Function<Entry<K,V>, ? extends U> searchFunction; |
5775 |
|
final AtomicReference<U> result; |
5776 |
|
if ((searchFunction = this.searchFunction) != null && |
5789 |
|
propagateCompletion(); |
5790 |
|
break; |
5791 |
|
} |
5792 |
< |
if ((u = searchFunction.apply(entryFor((K)nextKey, |
5792 |
> |
if ((u = searchFunction.apply(entryFor(nextKey, |
5793 |
|
v))) != null) { |
5794 |
|
if (result.compareAndSet(null, u)) |
5795 |
|
quietlyCompleteRoot(); |
5812 |
|
this.searchFunction = searchFunction; this.result = result; |
5813 |
|
} |
5814 |
|
public final U getRawResult() { return result.get(); } |
5815 |
< |
@SuppressWarnings("unchecked") public final void compute() { |
5815 |
> |
public final void compute() { |
5816 |
|
final BiFunction<? super K, ? super V, ? extends U> searchFunction; |
5817 |
|
final AtomicReference<U> result; |
5818 |
|
if ((searchFunction = this.searchFunction) != null && |
5831 |
|
propagateCompletion(); |
5832 |
|
break; |
5833 |
|
} |
5834 |
< |
if ((u = searchFunction.apply((K)nextKey, v)) != null) { |
5834 |
> |
if ((u = searchFunction.apply(nextKey, v)) != null) { |
5835 |
|
if (result.compareAndSet(null, u)) |
5836 |
|
quietlyCompleteRoot(); |
5837 |
|
break; |
5862 |
|
(map, this, b, rights, reducer)).fork(); |
5863 |
|
K r = null; |
5864 |
|
while (advance() != null) { |
5865 |
< |
K u = (K)nextKey; |
5865 |
> |
K u = nextKey; |
5866 |
|
r = (r == null) ? u : u == null ? r : reducer.apply(r, u); |
5867 |
|
} |
5868 |
|
result = r; |
5945 |
|
Map.Entry<K,V> r = null; |
5946 |
|
V v; |
5947 |
|
while ((v = advance()) != null) { |
5948 |
< |
Map.Entry<K,V> u = entryFor((K)nextKey, v); |
5948 |
> |
Map.Entry<K,V> u = entryFor(nextKey, v); |
5949 |
|
r = (r == null) ? u : reducer.apply(r, u); |
5950 |
|
} |
5951 |
|
result = r; |
5992 |
|
(map, this, b, rights, transformer, reducer)).fork(); |
5993 |
|
U r = null, u; |
5994 |
|
while (advance() != null) { |
5995 |
< |
if ((u = transformer.apply((K)nextKey)) != null) |
5995 |
> |
if ((u = transformer.apply(nextKey)) != null) |
5996 |
|
r = (r == null) ? u : reducer.apply(r, u); |
5997 |
|
} |
5998 |
|
result = r; |
6088 |
|
U r = null, u; |
6089 |
|
V v; |
6090 |
|
while ((v = advance()) != null) { |
6091 |
< |
if ((u = transformer.apply(entryFor((K)nextKey, |
6091 |
> |
if ((u = transformer.apply(entryFor(nextKey, |
6092 |
|
v))) != null) |
6093 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6094 |
|
} |
6137 |
|
U r = null, u; |
6138 |
|
V v; |
6139 |
|
while ((v = advance()) != null) { |
6140 |
< |
if ((u = transformer.apply((K)nextKey, v)) != null) |
6140 |
> |
if ((u = transformer.apply(nextKey, v)) != null) |
6141 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6142 |
|
} |
6143 |
|
result = r; |
6186 |
|
(rights = new MapReduceKeysToDoubleTask<K,V> |
6187 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6188 |
|
while (advance() != null) |
6189 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble((K)nextKey)); |
6189 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(nextKey)); |
6190 |
|
result = r; |
6191 |
|
CountedCompleter<?> c; |
6192 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6276 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6277 |
|
V v; |
6278 |
|
while ((v = advance()) != null) |
6279 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(entryFor((K)nextKey, |
6279 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(entryFor(nextKey, |
6280 |
|
v))); |
6281 |
|
result = r; |
6282 |
|
CountedCompleter<?> c; |
6322 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6323 |
|
V v; |
6324 |
|
while ((v = advance()) != null) |
6325 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble((K)nextKey, v)); |
6325 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(nextKey, v)); |
6326 |
|
result = r; |
6327 |
|
CountedCompleter<?> c; |
6328 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6366 |
|
(rights = new MapReduceKeysToLongTask<K,V> |
6367 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6368 |
|
while (advance() != null) |
6369 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong((K)nextKey)); |
6369 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(nextKey)); |
6370 |
|
result = r; |
6371 |
|
CountedCompleter<?> c; |
6372 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6456 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6457 |
|
V v; |
6458 |
|
while ((v = advance()) != null) |
6459 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong(entryFor((K)nextKey, v))); |
6459 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(entryFor(nextKey, v))); |
6460 |
|
result = r; |
6461 |
|
CountedCompleter<?> c; |
6462 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6501 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6502 |
|
V v; |
6503 |
|
while ((v = advance()) != null) |
6504 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong((K)nextKey, v)); |
6504 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(nextKey, v)); |
6505 |
|
result = r; |
6506 |
|
CountedCompleter<?> c; |
6507 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6545 |
|
(rights = new MapReduceKeysToIntTask<K,V> |
6546 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6547 |
|
while (advance() != null) |
6548 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt((K)nextKey)); |
6548 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(nextKey)); |
6549 |
|
result = r; |
6550 |
|
CountedCompleter<?> c; |
6551 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6635 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6636 |
|
V v; |
6637 |
|
while ((v = advance()) != null) |
6638 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt(entryFor((K)nextKey, |
6638 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(entryFor(nextKey, |
6639 |
|
v))); |
6640 |
|
result = r; |
6641 |
|
CountedCompleter<?> c; |
6681 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6682 |
|
V v; |
6683 |
|
while ((v = advance()) != null) |
6684 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt((K)nextKey, v)); |
6684 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(nextKey, v)); |
6685 |
|
result = r; |
6686 |
|
CountedCompleter<?> c; |
6687 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |