2145 |
|
* updated (nulled out) when the iterator cannot advance. |
2146 |
|
* |
2147 |
|
* Internal traversals directly access these fields, as in: |
2148 |
< |
* {@code while (it.advance() != null) { process(it.nextKey); }} |
2148 |
> |
* {@code while (it.advanceValue() != null) { process(it.nextKey); }} |
2149 |
|
* |
2150 |
|
* Exported iterators must track whether the iterator has advanced |
2151 |
|
* (in hasNext vs next) (by setting/checking/nulling field |
2251 |
|
* Advances next; returns nextVal or null if terminated. |
2252 |
|
* See above for explanation. |
2253 |
|
*/ |
2254 |
< |
@SuppressWarnings("unchecked") final V advance() { |
2254 |
> |
@SuppressWarnings("unchecked") final V advanceValue() { |
2255 |
> |
V v; |
2256 |
|
Node<V> e = next; |
2256 |
– |
V ev = null; |
2257 |
|
outer: do { |
2258 |
|
if (e != null) // advance past used/skipped node |
2259 |
|
e = e.next; |
2260 |
|
while (e == null) { // get to next non-null bin |
2261 |
– |
ConcurrentHashMap<K,V> m; |
2261 |
|
Node<V>[] t; int b, i, n; Object ek; // must use locals |
2262 |
< |
if ((t = tab) != null) |
2263 |
< |
n = t.length; |
2264 |
< |
else if ((m = map) != null && (t = tab = m.table) != null) |
2266 |
< |
n = baseLimit = baseSize = t.length; |
2267 |
< |
else |
2268 |
< |
break outer; |
2269 |
< |
if ((b = baseIndex) >= baseLimit || |
2270 |
< |
(i = index) < 0 || i >= n) |
2262 |
> |
if ((t = tab) == null || (n = t.length) <= (i = index) || |
2263 |
> |
i < 0 || (b = baseIndex) >= baseLimit) { |
2264 |
> |
v = null; |
2265 |
|
break outer; |
2266 |
+ |
} |
2267 |
|
if ((e = tabAt(t, i)) != null && e.hash < 0) { |
2268 |
|
if ((ek = e.key) instanceof TreeBin) |
2269 |
|
e = ((TreeBin<V>)ek).first; |
2274 |
|
} // visit upper slots if present |
2275 |
|
index = (i += baseSize) < n ? i : (baseIndex = b + 1); |
2276 |
|
} |
2277 |
< |
nextKey = (K)e.key; |
2278 |
< |
} while ((ev = e.val) == null); // skip deleted or special nodes |
2277 |
> |
nextKey = (K)e.key; // skip deleted or special nodes |
2278 |
> |
} while ((v = e.val) == null); |
2279 |
> |
next = e; |
2280 |
> |
return nextVal = v; |
2281 |
> |
} |
2282 |
> |
|
2283 |
> |
// Same idea, but with fewer accesses for key traversals |
2284 |
> |
@SuppressWarnings("unchecked") final K advanceKey() { |
2285 |
> |
K k; |
2286 |
> |
Node<V> e = next; |
2287 |
> |
outer: do { |
2288 |
> |
if (e != null) |
2289 |
> |
e = e.next; |
2290 |
> |
while (e == null) { |
2291 |
> |
Node<V>[] t; int b, i, n; Object ek; |
2292 |
> |
if ((t = tab) == null || (n = t.length) <= (i = index) || |
2293 |
> |
i < 0 || (b = baseIndex) >= baseLimit) { |
2294 |
> |
nextVal = null; |
2295 |
> |
k = null; |
2296 |
> |
break outer; |
2297 |
> |
} |
2298 |
> |
if ((e = tabAt(t, i)) != null && e.hash < 0) { |
2299 |
> |
if ((ek = e.key) instanceof TreeBin) |
2300 |
> |
e = ((TreeBin<V>)ek).first; |
2301 |
> |
else { |
2302 |
> |
tab = (Node<V>[])ek; |
2303 |
> |
continue; |
2304 |
> |
} |
2305 |
> |
} |
2306 |
> |
index = (i += baseSize) < n ? i : (baseIndex = b + 1); |
2307 |
> |
} |
2308 |
> |
k = (K)e.key; |
2309 |
> |
} while ((nextVal = e.val) == null); |
2310 |
|
next = e; |
2311 |
< |
return nextVal = ev; |
2311 |
> |
return nextKey = k; |
2312 |
|
} |
2313 |
|
|
2314 |
|
public final void remove() { |
2315 |
|
K k = nextKey; |
2316 |
< |
if (k == null && (advance() == null || (k = nextKey) == null)) |
2316 |
> |
if (k == null && (advanceValue() == null || (k = nextKey) == null)) |
2317 |
|
throw new IllegalStateException(); |
2318 |
|
map.internalReplace(k, null, null); |
2319 |
|
} |
2320 |
|
|
2321 |
|
public final boolean hasNext() { |
2322 |
< |
return nextVal != null || advance() != null; |
2322 |
> |
return nextVal != null || advanceValue() != null; |
2323 |
|
} |
2324 |
|
|
2325 |
|
public final boolean hasMoreElements() { return hasNext(); } |
2356 |
|
public long estimateSize() { |
2357 |
|
return batch; |
2358 |
|
} |
2359 |
+ |
|
2360 |
|
} |
2361 |
|
|
2362 |
|
/* ---------------- Public operations -------------- */ |
2560 |
|
throw new NullPointerException(); |
2561 |
|
V v; |
2562 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
2563 |
< |
while ((v = it.advance()) != null) { |
2563 |
> |
while ((v = it.advanceValue()) != null) { |
2564 |
|
if (v == value || value.equals(v)) |
2565 |
|
return true; |
2566 |
|
} |
2879 |
|
int h = 0; |
2880 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
2881 |
|
V v; |
2882 |
< |
while ((v = it.advance()) != null) { |
2882 |
> |
while ((v = it.advanceValue()) != null) { |
2883 |
|
h += it.nextKey.hashCode() ^ v.hashCode(); |
2884 |
|
} |
2885 |
|
return h; |
2901 |
|
StringBuilder sb = new StringBuilder(); |
2902 |
|
sb.append('{'); |
2903 |
|
V v; |
2904 |
< |
if ((v = it.advance()) != null) { |
2904 |
> |
if ((v = it.advanceValue()) != null) { |
2905 |
|
for (;;) { |
2906 |
|
K k = it.nextKey; |
2907 |
|
sb.append(k == this ? "(this Map)" : k); |
2908 |
|
sb.append('='); |
2909 |
|
sb.append(v == this ? "(this Map)" : v); |
2910 |
< |
if ((v = it.advance()) == null) |
2910 |
> |
if ((v = it.advanceValue()) == null) |
2911 |
|
break; |
2912 |
|
sb.append(',').append(' '); |
2913 |
|
} |
2932 |
|
Map<?,?> m = (Map<?,?>) o; |
2933 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
2934 |
|
V val; |
2935 |
< |
while ((val = it.advance()) != null) { |
2935 |
> |
while ((val = it.advanceValue()) != null) { |
2936 |
|
Object v = m.get(it.nextKey); |
2937 |
|
if (v == null || (v != val && !v.equals(val))) |
2938 |
|
return false; |
2959 |
|
super(map, it); |
2960 |
|
} |
2961 |
|
public KeyIterator<K,V> trySplit() { |
2962 |
< |
if (tab != null && baseIndex == baseLimit) |
2963 |
< |
return null; |
2937 |
< |
return new KeyIterator<K,V>(map, this); |
2962 |
> |
return (baseIndex == baseLimit) ? null : |
2963 |
> |
new KeyIterator<K,V>(map, this); |
2964 |
|
} |
2965 |
|
public final K next() { |
2966 |
< |
if (nextVal == null && advance() == null) |
2966 |
> |
K k; |
2967 |
> |
if ((k = (nextVal == null) ? advanceKey() : nextKey) == null) |
2968 |
|
throw new NoSuchElementException(); |
2942 |
– |
K k = nextKey; |
2969 |
|
nextVal = null; |
2970 |
|
return k; |
2971 |
|
} |
2976 |
|
|
2977 |
|
public void forEach(Consumer<? super K> action) { |
2978 |
|
if (action == null) throw new NullPointerException(); |
2979 |
< |
while (advance() != null) |
2980 |
< |
action.accept(nextKey); |
2979 |
> |
K k; |
2980 |
> |
while ((k = advanceKey()) != null) |
2981 |
> |
action.accept(k); |
2982 |
|
} |
2983 |
|
|
2984 |
|
public boolean tryAdvance(Consumer<? super K> block) { |
2985 |
|
if (block == null) throw new NullPointerException(); |
2986 |
< |
if (advance() == null) |
2986 |
> |
K k; |
2987 |
> |
if ((k = advanceKey()) == null) |
2988 |
|
return false; |
2989 |
< |
block.accept(nextKey); |
2989 |
> |
block.accept(k); |
2990 |
|
return true; |
2991 |
|
} |
2992 |
|
|
3005 |
|
super(map, it); |
3006 |
|
} |
3007 |
|
public ValueIterator<K,V> trySplit() { |
3008 |
< |
if (tab != null && baseIndex == baseLimit) |
3009 |
< |
return null; |
2982 |
< |
return new ValueIterator<K,V>(map, this); |
3008 |
> |
return (baseIndex == baseLimit) ? null : |
3009 |
> |
new ValueIterator<K,V>(map, this); |
3010 |
|
} |
3011 |
|
|
3012 |
|
public final V next() { |
3013 |
|
V v; |
3014 |
< |
if ((v = nextVal) == null && (v = advance()) == null) |
3014 |
> |
if ((v = nextVal) == null && (v = advanceValue()) == null) |
3015 |
|
throw new NoSuchElementException(); |
3016 |
|
nextVal = null; |
3017 |
|
return v; |
3024 |
|
public void forEach(Consumer<? super V> action) { |
3025 |
|
if (action == null) throw new NullPointerException(); |
3026 |
|
V v; |
3027 |
< |
while ((v = advance()) != null) |
3027 |
> |
while ((v = advanceValue()) != null) |
3028 |
|
action.accept(v); |
3029 |
|
} |
3030 |
|
|
3031 |
|
public boolean tryAdvance(Consumer<? super V> block) { |
3032 |
|
V v; |
3033 |
|
if (block == null) throw new NullPointerException(); |
3034 |
< |
if ((v = advance()) == null) |
3034 |
> |
if ((v = advanceValue()) == null) |
3035 |
|
return false; |
3036 |
|
block.accept(v); |
3037 |
|
return true; |
3050 |
|
super(map, it); |
3051 |
|
} |
3052 |
|
public EntryIterator<K,V> trySplit() { |
3053 |
< |
if (tab != null && baseIndex == baseLimit) |
3054 |
< |
return null; |
3028 |
< |
return new EntryIterator<K,V>(map, this); |
3053 |
> |
return (baseIndex == baseLimit) ? null : |
3054 |
> |
new EntryIterator<K,V>(map, this); |
3055 |
|
} |
3056 |
|
|
3057 |
|
public final Map.Entry<K,V> next() { |
3058 |
|
V v; |
3059 |
< |
if ((v = nextVal) == null && (v = advance()) == null) |
3059 |
> |
if ((v = nextVal) == null && (v = advanceValue()) == null) |
3060 |
|
throw new NoSuchElementException(); |
3061 |
|
K k = nextKey; |
3062 |
|
nextVal = null; |
3068 |
|
public void forEach(Consumer<? super Map.Entry<K,V>> action) { |
3069 |
|
if (action == null) throw new NullPointerException(); |
3070 |
|
V v; |
3071 |
< |
while ((v = advance()) != null) |
3071 |
> |
while ((v = advanceValue()) != null) |
3072 |
|
action.accept(entryFor(nextKey, v)); |
3073 |
|
} |
3074 |
|
|
3075 |
|
public boolean tryAdvance(Consumer<? super Map.Entry<K,V>> block) { |
3076 |
|
V v; |
3077 |
|
if (block == null) throw new NullPointerException(); |
3078 |
< |
if ((v = advance()) == null) |
3078 |
> |
if ((v = advanceValue()) == null) |
3079 |
|
return false; |
3080 |
|
block.accept(entryFor(nextKey, v)); |
3081 |
|
return true; |
3171 |
|
s.defaultWriteObject(); |
3172 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3173 |
|
V v; |
3174 |
< |
while ((v = it.advance()) != null) { |
3174 |
> |
while ((v = it.advanceValue()) != null) { |
3175 |
|
s.writeObject(it.nextKey); |
3176 |
|
s.writeObject(v); |
3177 |
|
} |
3276 |
|
if (action == null) throw new NullPointerException(); |
3277 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3278 |
|
V v; |
3279 |
< |
while ((v = it.advance()) != null) |
3279 |
> |
while ((v = it.advanceValue()) != null) |
3280 |
|
action.accept(it.nextKey, v); |
3281 |
|
} |
3282 |
|
|
3296 |
|
throw new NullPointerException(); |
3297 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3298 |
|
V v; U u; |
3299 |
< |
while ((v = it.advance()) != null) { |
3299 |
> |
while ((v = it.advanceValue()) != null) { |
3300 |
|
if ((u = transformer.apply(it.nextKey, v)) != null) |
3301 |
|
action.accept(u); |
3302 |
|
} |
3316 |
|
if (searchFunction == null) throw new NullPointerException(); |
3317 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3318 |
|
V v; U u; |
3319 |
< |
while ((v = it.advance()) != null) { |
3319 |
> |
while ((v = it.advanceValue()) != null) { |
3320 |
|
if ((u = searchFunction.apply(it.nextKey, v)) != null) |
3321 |
|
return u; |
3322 |
|
} |
3342 |
|
throw new NullPointerException(); |
3343 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3344 |
|
U r = null, u; V v; |
3345 |
< |
while ((v = it.advance()) != null) { |
3345 |
> |
while ((v = it.advanceValue()) != null) { |
3346 |
|
if ((u = transformer.apply(it.nextKey, v)) != null) |
3347 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3348 |
|
} |
3369 |
|
throw new NullPointerException(); |
3370 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3371 |
|
double r = basis; V v; |
3372 |
< |
while ((v = it.advance()) != null) |
3372 |
> |
while ((v = it.advanceValue()) != null) |
3373 |
|
r = reducer.applyAsDouble(r, transformer.applyAsDouble(it.nextKey, v)); |
3374 |
|
return r; |
3375 |
|
} |
3394 |
|
throw new NullPointerException(); |
3395 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3396 |
|
long r = basis; V v; |
3397 |
< |
while ((v = it.advance()) != null) |
3397 |
> |
while ((v = it.advanceValue()) != null) |
3398 |
|
r = reducer.applyAsLong(r, transformer.applyAsLong(it.nextKey, v)); |
3399 |
|
return r; |
3400 |
|
} |
3419 |
|
throw new NullPointerException(); |
3420 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3421 |
|
int r = basis; V v; |
3422 |
< |
while ((v = it.advance()) != null) |
3422 |
> |
while ((v = it.advanceValue()) != null) |
3423 |
|
r = reducer.applyAsInt(r, transformer.applyAsInt(it.nextKey, v)); |
3424 |
|
return r; |
3425 |
|
} |
3433 |
|
(Consumer<? super K> action) { |
3434 |
|
if (action == null) throw new NullPointerException(); |
3435 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3436 |
< |
while (it.advance() != null) |
3437 |
< |
action.accept(it.nextKey); |
3436 |
> |
K k; |
3437 |
> |
while ((k = it.advanceKey()) != null) |
3438 |
> |
action.accept(k); |
3439 |
|
} |
3440 |
|
|
3441 |
|
/** |
3453 |
|
if (transformer == null || action == null) |
3454 |
|
throw new NullPointerException(); |
3455 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3456 |
< |
U u; |
3457 |
< |
while (it.advance() != null) { |
3458 |
< |
if ((u = transformer.apply(it.nextKey)) != null) |
3456 |
> |
K k; U u; |
3457 |
> |
while ((k = it.advanceKey()) != null) { |
3458 |
> |
if ((u = transformer.apply(k)) != null) |
3459 |
|
action.accept(u); |
3460 |
|
} |
3461 |
|
ForkJoinTasks.forEachKey |
3474 |
|
public <U> U searchKeysSequentially |
3475 |
|
(Function<? super K, ? extends U> searchFunction) { |
3476 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3477 |
< |
U u; |
3478 |
< |
while (it.advance() != null) { |
3479 |
< |
if ((u = searchFunction.apply(it.nextKey)) != null) |
3477 |
> |
K k; U u; |
3478 |
> |
while ((k = it.advanceKey()) != null) { |
3479 |
> |
if ((u = searchFunction.apply(k)) != null) |
3480 |
|
return u; |
3481 |
|
} |
3482 |
|
return null; |
3494 |
|
(BiFunction<? super K, ? super K, ? extends K> reducer) { |
3495 |
|
if (reducer == null) throw new NullPointerException(); |
3496 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3497 |
< |
K r = null; |
3498 |
< |
while (it.advance() != null) { |
3472 |
< |
K u = it.nextKey; |
3497 |
> |
K u, r = null; |
3498 |
> |
while ((u = it.advanceKey()) != null) { |
3499 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3500 |
|
} |
3501 |
|
return r; |
3519 |
|
if (transformer == null || reducer == null) |
3520 |
|
throw new NullPointerException(); |
3521 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3522 |
< |
U r = null, u; |
3523 |
< |
while (it.advance() != null) { |
3524 |
< |
if ((u = transformer.apply(it.nextKey)) != null) |
3522 |
> |
K k; U r = null, u; |
3523 |
> |
while ((k = it.advanceKey()) != null) { |
3524 |
> |
if ((u = transformer.apply(k)) != null) |
3525 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3526 |
|
} |
3527 |
|
return r; |
3547 |
|
throw new NullPointerException(); |
3548 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3549 |
|
double r = basis; |
3550 |
< |
while (it.advance() != null) |
3551 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(it.nextKey)); |
3550 |
> |
K k; |
3551 |
> |
while ((k = it.advanceKey()) != null) |
3552 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(k)); |
3553 |
|
return r; |
3554 |
|
} |
3555 |
|
|
3573 |
|
throw new NullPointerException(); |
3574 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3575 |
|
long r = basis; |
3576 |
< |
while (it.advance() != null) |
3577 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong(it.nextKey)); |
3576 |
> |
K k; |
3577 |
> |
while ((k = it.advanceKey()) != null) |
3578 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(k)); |
3579 |
|
return r; |
3580 |
|
} |
3581 |
|
|
3599 |
|
throw new NullPointerException(); |
3600 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3601 |
|
int r = basis; |
3602 |
< |
while (it.advance() != null) |
3603 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt(it.nextKey)); |
3602 |
> |
K k; |
3603 |
> |
while ((k = it.advanceKey()) != null) |
3604 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(k)); |
3605 |
|
return r; |
3606 |
|
} |
3607 |
|
|
3614 |
|
if (action == null) throw new NullPointerException(); |
3615 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3616 |
|
V v; |
3617 |
< |
while ((v = it.advance()) != null) |
3617 |
> |
while ((v = it.advanceValue()) != null) |
3618 |
|
action.accept(v); |
3619 |
|
} |
3620 |
|
|
3634 |
|
throw new NullPointerException(); |
3635 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3636 |
|
V v; U u; |
3637 |
< |
while ((v = it.advance()) != null) { |
3637 |
> |
while ((v = it.advanceValue()) != null) { |
3638 |
|
if ((u = transformer.apply(v)) != null) |
3639 |
|
action.accept(u); |
3640 |
|
} |
3654 |
|
if (searchFunction == null) throw new NullPointerException(); |
3655 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3656 |
|
V v; U u; |
3657 |
< |
while ((v = it.advance()) != null) { |
3657 |
> |
while ((v = it.advanceValue()) != null) { |
3658 |
|
if ((u = searchFunction.apply(v)) != null) |
3659 |
|
return u; |
3660 |
|
} |
3673 |
|
if (reducer == null) throw new NullPointerException(); |
3674 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3675 |
|
V r = null; V v; |
3676 |
< |
while ((v = it.advance()) != null) |
3676 |
> |
while ((v = it.advanceValue()) != null) |
3677 |
|
r = (r == null) ? v : reducer.apply(r, v); |
3678 |
|
return r; |
3679 |
|
} |
3697 |
|
throw new NullPointerException(); |
3698 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3699 |
|
U r = null, u; V v; |
3700 |
< |
while ((v = it.advance()) != null) { |
3700 |
> |
while ((v = it.advanceValue()) != null) { |
3701 |
|
if ((u = transformer.apply(v)) != null) |
3702 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3703 |
|
} |
3724 |
|
throw new NullPointerException(); |
3725 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3726 |
|
double r = basis; V v; |
3727 |
< |
while ((v = it.advance()) != null) |
3727 |
> |
while ((v = it.advanceValue()) != null) |
3728 |
|
r = reducer.applyAsDouble(r, transformer.applyAsDouble(v)); |
3729 |
|
return r; |
3730 |
|
} |
3749 |
|
throw new NullPointerException(); |
3750 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3751 |
|
long r = basis; V v; |
3752 |
< |
while ((v = it.advance()) != null) |
3752 |
> |
while ((v = it.advanceValue()) != null) |
3753 |
|
r = reducer.applyAsLong(r, transformer.applyAsLong(v)); |
3754 |
|
return r; |
3755 |
|
} |
3774 |
|
throw new NullPointerException(); |
3775 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3776 |
|
int r = basis; V v; |
3777 |
< |
while ((v = it.advance()) != null) |
3777 |
> |
while ((v = it.advanceValue()) != null) |
3778 |
|
r = reducer.applyAsInt(r, transformer.applyAsInt(v)); |
3779 |
|
return r; |
3780 |
|
} |
3789 |
|
if (action == null) throw new NullPointerException(); |
3790 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3791 |
|
V v; |
3792 |
< |
while ((v = it.advance()) != null) |
3792 |
> |
while ((v = it.advanceValue()) != null) |
3793 |
|
action.accept(entryFor(it.nextKey, v)); |
3794 |
|
} |
3795 |
|
|
3809 |
|
throw new NullPointerException(); |
3810 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3811 |
|
V v; U u; |
3812 |
< |
while ((v = it.advance()) != null) { |
3812 |
> |
while ((v = it.advanceValue()) != null) { |
3813 |
|
if ((u = transformer.apply(entryFor(it.nextKey, v))) != null) |
3814 |
|
action.accept(u); |
3815 |
|
} |
3829 |
|
if (searchFunction == null) throw new NullPointerException(); |
3830 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3831 |
|
V v; U u; |
3832 |
< |
while ((v = it.advance()) != null) { |
3832 |
> |
while ((v = it.advanceValue()) != null) { |
3833 |
|
if ((u = searchFunction.apply(entryFor(it.nextKey, v))) != null) |
3834 |
|
return u; |
3835 |
|
} |
3848 |
|
if (reducer == null) throw new NullPointerException(); |
3849 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3850 |
|
Map.Entry<K,V> r = null; V v; |
3851 |
< |
while ((v = it.advance()) != null) { |
3851 |
> |
while ((v = it.advanceValue()) != null) { |
3852 |
|
Map.Entry<K,V> u = entryFor(it.nextKey, v); |
3853 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3854 |
|
} |
3874 |
|
throw new NullPointerException(); |
3875 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3876 |
|
U r = null, u; V v; |
3877 |
< |
while ((v = it.advance()) != null) { |
3877 |
> |
while ((v = it.advanceValue()) != null) { |
3878 |
|
if ((u = transformer.apply(entryFor(it.nextKey, v))) != null) |
3879 |
|
r = (r == null) ? u : reducer.apply(r, u); |
3880 |
|
} |
3901 |
|
throw new NullPointerException(); |
3902 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3903 |
|
double r = basis; V v; |
3904 |
< |
while ((v = it.advance()) != null) |
3904 |
> |
while ((v = it.advanceValue()) != null) |
3905 |
|
r = reducer.applyAsDouble(r, transformer.applyAsDouble(entryFor(it.nextKey, v))); |
3906 |
|
return r; |
3907 |
|
} |
3926 |
|
throw new NullPointerException(); |
3927 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3928 |
|
long r = basis; V v; |
3929 |
< |
while ((v = it.advance()) != null) |
3929 |
> |
while ((v = it.advanceValue()) != null) |
3930 |
|
r = reducer.applyAsLong(r, transformer.applyAsLong(entryFor(it.nextKey, v))); |
3931 |
|
return r; |
3932 |
|
} |
3951 |
|
throw new NullPointerException(); |
3952 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3953 |
|
int r = basis; V v; |
3954 |
< |
while ((v = it.advance()) != null) |
3954 |
> |
while ((v = it.advanceValue()) != null) |
3955 |
|
r = reducer.applyAsInt(r, transformer.applyAsInt(entryFor(it.nextKey, v))); |
3956 |
|
return r; |
3957 |
|
} |
4768 |
|
return added; |
4769 |
|
} |
4770 |
|
|
4771 |
+ |
Spliterator<K> spliterator() { |
4772 |
+ |
return new KeyIterator<>(map, null); |
4773 |
+ |
} |
4774 |
+ |
|
4775 |
|
public Stream<K> stream() { |
4776 |
< |
return Streams.stream(new KeyIterator<>(map, null)); |
4776 |
> |
return Streams.stream(spliterator()); |
4777 |
|
} |
4778 |
|
public Stream<K> parallelStream() { |
4779 |
< |
return Streams.parallelStream(new KeyIterator<K,V>(map, null)); |
4779 |
> |
return Streams.parallelStream(spliterator()); |
4780 |
|
} |
4781 |
|
} |
4782 |
|
|
4827 |
|
throw new UnsupportedOperationException(); |
4828 |
|
} |
4829 |
|
|
4830 |
+ |
Spliterator<V> spliterator() { |
4831 |
+ |
return new ValueIterator<K,V>(map, null); |
4832 |
+ |
} |
4833 |
+ |
|
4834 |
|
public Stream<V> stream() { |
4835 |
< |
return Streams.stream(new ValueIterator<K,V>(map, null)); |
4835 |
> |
return Streams.stream(spliterator()); |
4836 |
|
} |
4837 |
|
|
4838 |
|
public Stream<V> parallelStream() { |
4839 |
< |
return Streams.parallelStream(new ValueIterator<K,V>(map, null)); |
4839 |
> |
return Streams.parallelStream(spliterator()); |
4840 |
|
} |
4841 |
|
|
4842 |
|
} |
4903 |
|
return added; |
4904 |
|
} |
4905 |
|
|
4906 |
+ |
Spliterator<Map.Entry<K,V>> spliterator() { |
4907 |
+ |
return new EntryIterator<K,V>(map, null); |
4908 |
+ |
} |
4909 |
+ |
|
4910 |
|
public Stream<Map.Entry<K,V>> stream() { |
4911 |
< |
return Streams.stream(new EntryIterator<K,V>(map, null)); |
4911 |
> |
return Streams.stream(spliterator()); |
4912 |
|
} |
4913 |
|
|
4914 |
|
public Stream<Map.Entry<K,V>> parallelStream() { |
4915 |
< |
return Streams.parallelStream(new EntryIterator<K,V>(map, null)); |
4915 |
> |
return Streams.parallelStream(spliterator()); |
4916 |
|
} |
4917 |
|
} |
4918 |
|
|
5610 |
|
if ((action = this.action) != null) { |
5611 |
|
for (int b; (b = preSplit()) > 0;) |
5612 |
|
new ForEachKeyTask<K,V>(map, this, b, action).fork(); |
5613 |
< |
while (advance() != null) |
5614 |
< |
action.accept(nextKey); |
5613 |
> |
K k; |
5614 |
> |
while ((k = advanceKey()) != null) |
5615 |
> |
action.accept(k); |
5616 |
|
propagateCompletion(); |
5617 |
|
} |
5618 |
|
} |
5633 |
|
for (int b; (b = preSplit()) > 0;) |
5634 |
|
new ForEachValueTask<K,V>(map, this, b, action).fork(); |
5635 |
|
V v; |
5636 |
< |
while ((v = advance()) != null) |
5636 |
> |
while ((v = advanceValue()) != null) |
5637 |
|
action.accept(v); |
5638 |
|
propagateCompletion(); |
5639 |
|
} |
5655 |
|
for (int b; (b = preSplit()) > 0;) |
5656 |
|
new ForEachEntryTask<K,V>(map, this, b, action).fork(); |
5657 |
|
V v; |
5658 |
< |
while ((v = advance()) != null) |
5658 |
> |
while ((v = advanceValue()) != null) |
5659 |
|
action.accept(entryFor(nextKey, v)); |
5660 |
|
propagateCompletion(); |
5661 |
|
} |
5677 |
|
for (int b; (b = preSplit()) > 0;) |
5678 |
|
new ForEachMappingTask<K,V>(map, this, b, action).fork(); |
5679 |
|
V v; |
5680 |
< |
while ((v = advance()) != null) |
5680 |
> |
while ((v = advanceValue()) != null) |
5681 |
|
action.accept(nextKey, v); |
5682 |
|
propagateCompletion(); |
5683 |
|
} |
5702 |
|
for (int b; (b = preSplit()) > 0;) |
5703 |
|
new ForEachTransformedKeyTask<K,V,U> |
5704 |
|
(map, this, b, transformer, action).fork(); |
5705 |
< |
U u; |
5706 |
< |
while (advance() != null) { |
5707 |
< |
if ((u = transformer.apply(nextKey)) != null) |
5705 |
> |
K k; U u; |
5706 |
> |
while ((k = advanceKey()) != null) { |
5707 |
> |
if ((u = transformer.apply(k)) != null) |
5708 |
|
action.accept(u); |
5709 |
|
} |
5710 |
|
propagateCompletion(); |
5731 |
|
new ForEachTransformedValueTask<K,V,U> |
5732 |
|
(map, this, b, transformer, action).fork(); |
5733 |
|
V v; U u; |
5734 |
< |
while ((v = advance()) != null) { |
5734 |
> |
while ((v = advanceValue()) != null) { |
5735 |
|
if ((u = transformer.apply(v)) != null) |
5736 |
|
action.accept(u); |
5737 |
|
} |
5759 |
|
new ForEachTransformedEntryTask<K,V,U> |
5760 |
|
(map, this, b, transformer, action).fork(); |
5761 |
|
V v; U u; |
5762 |
< |
while ((v = advance()) != null) { |
5762 |
> |
while ((v = advanceValue()) != null) { |
5763 |
|
if ((u = transformer.apply(entryFor(nextKey, |
5764 |
|
v))) != null) |
5765 |
|
action.accept(u); |
5789 |
|
new ForEachTransformedMappingTask<K,V,U> |
5790 |
|
(map, this, b, transformer, action).fork(); |
5791 |
|
V v; U u; |
5792 |
< |
while ((v = advance()) != null) { |
5792 |
> |
while ((v = advanceValue()) != null) { |
5793 |
|
if ((u = transformer.apply(nextKey, v)) != null) |
5794 |
|
action.accept(u); |
5795 |
|
} |
5824 |
|
(map, this, b, searchFunction, result).fork(); |
5825 |
|
} |
5826 |
|
while (result.get() == null) { |
5827 |
< |
U u; |
5828 |
< |
if (advance() == null) { |
5827 |
> |
K k; U u; |
5828 |
> |
if ((k = advanceKey()) == null) { |
5829 |
|
propagateCompletion(); |
5830 |
|
break; |
5831 |
|
} |
5832 |
< |
if ((u = searchFunction.apply(nextKey)) != null) { |
5832 |
> |
if ((u = searchFunction.apply(k)) != null) { |
5833 |
|
if (result.compareAndSet(null, u)) |
5834 |
|
quietlyCompleteRoot(); |
5835 |
|
break; |
5866 |
|
} |
5867 |
|
while (result.get() == null) { |
5868 |
|
V v; U u; |
5869 |
< |
if ((v = advance()) == null) { |
5869 |
> |
if ((v = advanceValue()) == null) { |
5870 |
|
propagateCompletion(); |
5871 |
|
break; |
5872 |
|
} |
5907 |
|
} |
5908 |
|
while (result.get() == null) { |
5909 |
|
V v; U u; |
5910 |
< |
if ((v = advance()) == null) { |
5910 |
> |
if ((v = advanceValue()) == null) { |
5911 |
|
propagateCompletion(); |
5912 |
|
break; |
5913 |
|
} |
5949 |
|
} |
5950 |
|
while (result.get() == null) { |
5951 |
|
V v; U u; |
5952 |
< |
if ((v = advance()) == null) { |
5952 |
> |
if ((v = advanceValue()) == null) { |
5953 |
|
propagateCompletion(); |
5954 |
|
break; |
5955 |
|
} |
5982 |
|
for (int b; (b = preSplit()) > 0;) |
5983 |
|
(rights = new ReduceKeysTask<K,V> |
5984 |
|
(map, this, b, rights, reducer)).fork(); |
5985 |
< |
K r = null; |
5986 |
< |
while (advance() != null) { |
5945 |
< |
K u = nextKey; |
5985 |
> |
K u, r = null; |
5986 |
> |
while ((u = advanceKey()) != null) { |
5987 |
|
r = (r == null) ? u : u == null ? r : reducer.apply(r, u); |
5988 |
|
} |
5989 |
|
result = r; |
6024 |
|
(rights = new ReduceValuesTask<K,V> |
6025 |
|
(map, this, b, rights, reducer)).fork(); |
6026 |
|
V r = null, v; |
6027 |
< |
while ((v = advance()) != null) |
6027 |
> |
while ((v = advanceValue()) != null) |
6028 |
|
r = (r == null) ? v : reducer.apply(r, v); |
6029 |
|
result = r; |
6030 |
|
CountedCompleter<?> c; |
6065 |
|
(map, this, b, rights, reducer)).fork(); |
6066 |
|
Map.Entry<K,V> r = null; |
6067 |
|
V v; |
6068 |
< |
while ((v = advance()) != null) { |
6068 |
> |
while ((v = advanceValue()) != null) { |
6069 |
|
Map.Entry<K,V> u = entryFor(nextKey, v); |
6070 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6071 |
|
} |
6111 |
|
for (int b; (b = preSplit()) > 0;) |
6112 |
|
(rights = new MapReduceKeysTask<K,V,U> |
6113 |
|
(map, this, b, rights, transformer, reducer)).fork(); |
6114 |
< |
U r = null, u; |
6115 |
< |
while (advance() != null) { |
6116 |
< |
if ((u = transformer.apply(nextKey)) != null) |
6114 |
> |
K k; U r = null, u; |
6115 |
> |
while ((k = advanceKey()) != null) { |
6116 |
> |
if ((u = transformer.apply(k)) != null) |
6117 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6118 |
|
} |
6119 |
|
result = r; |
6160 |
|
(map, this, b, rights, transformer, reducer)).fork(); |
6161 |
|
U r = null, u; |
6162 |
|
V v; |
6163 |
< |
while ((v = advance()) != null) { |
6163 |
> |
while ((v = advanceValue()) != null) { |
6164 |
|
if ((u = transformer.apply(v)) != null) |
6165 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6166 |
|
} |
6208 |
|
(map, this, b, rights, transformer, reducer)).fork(); |
6209 |
|
U r = null, u; |
6210 |
|
V v; |
6211 |
< |
while ((v = advance()) != null) { |
6211 |
> |
while ((v = advanceValue()) != null) { |
6212 |
|
if ((u = transformer.apply(entryFor(nextKey, |
6213 |
|
v))) != null) |
6214 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6257 |
|
(map, this, b, rights, transformer, reducer)).fork(); |
6258 |
|
U r = null, u; |
6259 |
|
V v; |
6260 |
< |
while ((v = advance()) != null) { |
6260 |
> |
while ((v = advanceValue()) != null) { |
6261 |
|
if ((u = transformer.apply(nextKey, v)) != null) |
6262 |
|
r = (r == null) ? u : reducer.apply(r, u); |
6263 |
|
} |
6306 |
|
for (int b; (b = preSplit()) > 0;) |
6307 |
|
(rights = new MapReduceKeysToDoubleTask<K,V> |
6308 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6309 |
< |
while (advance() != null) |
6310 |
< |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(nextKey)); |
6309 |
> |
K k; |
6310 |
> |
while ((k = advanceKey()) != null) |
6311 |
> |
r = reducer.applyAsDouble(r, transformer.applyAsDouble(k)); |
6312 |
|
result = r; |
6313 |
|
CountedCompleter<?> c; |
6314 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6352 |
|
(rights = new MapReduceValuesToDoubleTask<K,V> |
6353 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6354 |
|
V v; |
6355 |
< |
while ((v = advance()) != null) |
6355 |
> |
while ((v = advanceValue()) != null) |
6356 |
|
r = reducer.applyAsDouble(r, transformer.applyAsDouble(v)); |
6357 |
|
result = r; |
6358 |
|
CountedCompleter<?> c; |
6397 |
|
(rights = new MapReduceEntriesToDoubleTask<K,V> |
6398 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6399 |
|
V v; |
6400 |
< |
while ((v = advance()) != null) |
6400 |
> |
while ((v = advanceValue()) != null) |
6401 |
|
r = reducer.applyAsDouble(r, transformer.applyAsDouble(entryFor(nextKey, |
6402 |
|
v))); |
6403 |
|
result = r; |
6443 |
|
(rights = new MapReduceMappingsToDoubleTask<K,V> |
6444 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6445 |
|
V v; |
6446 |
< |
while ((v = advance()) != null) |
6446 |
> |
while ((v = advanceValue()) != null) |
6447 |
|
r = reducer.applyAsDouble(r, transformer.applyAsDouble(nextKey, v)); |
6448 |
|
result = r; |
6449 |
|
CountedCompleter<?> c; |
6487 |
|
for (int b; (b = preSplit()) > 0;) |
6488 |
|
(rights = new MapReduceKeysToLongTask<K,V> |
6489 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6490 |
< |
while (advance() != null) |
6491 |
< |
r = reducer.applyAsLong(r, transformer.applyAsLong(nextKey)); |
6490 |
> |
K k; |
6491 |
> |
while ((k = advanceKey()) != null) |
6492 |
> |
r = reducer.applyAsLong(r, transformer.applyAsLong(k)); |
6493 |
|
result = r; |
6494 |
|
CountedCompleter<?> c; |
6495 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6533 |
|
(rights = new MapReduceValuesToLongTask<K,V> |
6534 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6535 |
|
V v; |
6536 |
< |
while ((v = advance()) != null) |
6536 |
> |
while ((v = advanceValue()) != null) |
6537 |
|
r = reducer.applyAsLong(r, transformer.applyAsLong(v)); |
6538 |
|
result = r; |
6539 |
|
CountedCompleter<?> c; |
6578 |
|
(rights = new MapReduceEntriesToLongTask<K,V> |
6579 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6580 |
|
V v; |
6581 |
< |
while ((v = advance()) != null) |
6581 |
> |
while ((v = advanceValue()) != null) |
6582 |
|
r = reducer.applyAsLong(r, transformer.applyAsLong(entryFor(nextKey, v))); |
6583 |
|
result = r; |
6584 |
|
CountedCompleter<?> c; |
6623 |
|
(rights = new MapReduceMappingsToLongTask<K,V> |
6624 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6625 |
|
V v; |
6626 |
< |
while ((v = advance()) != null) |
6626 |
> |
while ((v = advanceValue()) != null) |
6627 |
|
r = reducer.applyAsLong(r, transformer.applyAsLong(nextKey, v)); |
6628 |
|
result = r; |
6629 |
|
CountedCompleter<?> c; |
6667 |
|
for (int b; (b = preSplit()) > 0;) |
6668 |
|
(rights = new MapReduceKeysToIntTask<K,V> |
6669 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6670 |
< |
while (advance() != null) |
6671 |
< |
r = reducer.applyAsInt(r, transformer.applyAsInt(nextKey)); |
6670 |
> |
K k; |
6671 |
> |
while ((k = advanceKey()) != null) |
6672 |
> |
r = reducer.applyAsInt(r, transformer.applyAsInt(k)); |
6673 |
|
result = r; |
6674 |
|
CountedCompleter<?> c; |
6675 |
|
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
6713 |
|
(rights = new MapReduceValuesToIntTask<K,V> |
6714 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6715 |
|
V v; |
6716 |
< |
while ((v = advance()) != null) |
6716 |
> |
while ((v = advanceValue()) != null) |
6717 |
|
r = reducer.applyAsInt(r, transformer.applyAsInt(v)); |
6718 |
|
result = r; |
6719 |
|
CountedCompleter<?> c; |
6758 |
|
(rights = new MapReduceEntriesToIntTask<K,V> |
6759 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6760 |
|
V v; |
6761 |
< |
while ((v = advance()) != null) |
6761 |
> |
while ((v = advanceValue()) != null) |
6762 |
|
r = reducer.applyAsInt(r, transformer.applyAsInt(entryFor(nextKey, |
6763 |
|
v))); |
6764 |
|
result = r; |
6804 |
|
(rights = new MapReduceMappingsToIntTask<K,V> |
6805 |
|
(map, this, b, rights, transformer, r, reducer)).fork(); |
6806 |
|
V v; |
6807 |
< |
while ((v = advance()) != null) |
6807 |
> |
while ((v = advanceValue()) != null) |
6808 |
|
r = reducer.applyAsInt(r, transformer.applyAsInt(nextKey, v)); |
6809 |
|
result = r; |
6810 |
|
CountedCompleter<?> c; |