6 |
|
|
7 |
|
import junit.framework.*; |
8 |
|
import java.util.*; |
9 |
+ |
import static java.util.Spliterator.*; |
10 |
|
import java.util.function.*; |
11 |
|
import java.util.concurrent.atomic.LongAdder; |
12 |
|
import java.util.concurrent.ConcurrentHashMap; |
300 |
|
assertTrue(map.get(seven) == one); |
301 |
|
} |
302 |
|
|
303 |
+ |
void checkSpliteratorCharacteristics(Spliterator<?> sp, |
304 |
+ |
int requiredCharacteristics) { |
305 |
+ |
assertEquals(requiredCharacteristics, |
306 |
+ |
requiredCharacteristics & sp.characteristics()); |
307 |
+ |
} |
308 |
+ |
|
309 |
|
/** |
310 |
|
* KeySetView.spliterator returns spliterator over the elements in this set |
311 |
|
*/ |
314 |
|
ConcurrentHashMap map = map5(); |
315 |
|
Set set = map.keySet(); |
316 |
|
Spliterator<Integer> sp = set.spliterator(); |
317 |
+ |
checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL); |
318 |
|
assertEquals(sp.estimateSize(), map.size()); |
319 |
|
Spliterator<Integer> sp2 = sp.trySplit(); |
320 |
|
sp.forEachRemaining((Integer x) -> adder.add(x.longValue())); |