ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMap8Test.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMap8Test.java (file contents):
Revision 1.2 by dl, Fri Mar 22 00:24:35 2013 UTC vs.
Revision 1.7 by jsr166, Thu Apr 11 19:54:13 2013 UTC

# Line 6 | Line 6
6  
7   import junit.framework.*;
8   import java.util.*;
9 + import java.util.function.*;
10   import java.util.concurrent.atomic.LongAdder;
11   import java.util.concurrent.ConcurrentHashMap;
12  
# Line 33 | Line 34 | public class ConcurrentHashMap8Test exte
34          return map;
35      }
36  
37 +    // classes for testing Comparable fallbacks
38 +    static class BI implements Comparable<BI> {
39 +        private final int value;
40 +        BI(int value) { this.value = value; }
41 +        public int compareTo(BI other) {
42 +            return Integer.compare(value, other.value);
43 +        }
44 +        public boolean equals(Object x) {
45 +            return (x instanceof BI) && ((BI)x).value == value;
46 +        }
47 +        public int hashCode() { return 42; }
48 +    }
49 +    static class CI extends BI { CI(int value) { super(value); } }
50 +    static class DI extends BI { DI(int value) { super(value); } }
51 +
52 +    static class BS implements Comparable<BS> {
53 +        private final String value;
54 +        BS(String value) { this.value = value; }
55 +        public int compareTo(BS other) {
56 +            return value.compareTo(other.value);
57 +        }
58 +        public boolean equals(Object x) {
59 +            return (x instanceof BS) && value.equals(((BS)x).value);
60 +        }
61 +        public int hashCode() { return 42; }
62 +    }
63 +
64 +    static class LexicographicList<E extends Comparable<E>> extends ArrayList<E>
65 +        implements Comparable<LexicographicList<E>> {
66 +        LexicographicList(Collection<E> c) { super(c); }
67 +        LexicographicList(E e) { super(Collections.singleton(e)); }
68 +        public int compareTo(LexicographicList<E> other) {
69 +            int common = Math.min(size(), other.size());
70 +            int r = 0;
71 +            for (int i = 0; i < common; i++) {
72 +                if ((r = get(i).compareTo(other.get(i))) != 0)
73 +                    break;
74 +            }
75 +            if (r == 0)
76 +                r = Integer.compare(size(), other.size());
77 +            return r;
78 +        }
79 +        private static final long serialVersionUID = 0;
80 +    }
81 +
82 +    /**
83 +     * Inserted elements that are subclasses of the same Comparable
84 +     * class are found.
85 +     */
86 +    public void testComparableFamily() {
87 +        ConcurrentHashMap<BI, Boolean> m = new ConcurrentHashMap<>();
88 +        for (int i = 0; i < 1000; i++) {
89 +            assertTrue(m.put(new CI(i), true) == null);
90 +        }
91 +        for (int i = 0; i < 1000; i++) {
92 +            assertTrue(m.containsKey(new CI(i)));
93 +            assertTrue(m.containsKey(new DI(i)));
94 +        }
95 +    }
96 +
97 +    /**
98 +     * Elements of classes with erased generic type parameters based
99 +     * on Comparable can be inserted and found.
100 +     */
101 +    public void testGenericComparable() {
102 +        ConcurrentHashMap<Object, Boolean> m = new ConcurrentHashMap<>();
103 +        for (int i = 0; i < 1000; i++) {
104 +            BI bi = new BI(i);
105 +            BS bs = new BS(String.valueOf(i));
106 +            LexicographicList<BI> bis = new LexicographicList<BI>(bi);
107 +            LexicographicList<BS> bss = new LexicographicList<BS>(bs);
108 +            assertTrue(m.putIfAbsent(bis, true) == null);
109 +            assertTrue(m.containsKey(bis));
110 +            if (m.putIfAbsent(bss, true) == null)
111 +                assertTrue(m.containsKey(bss));
112 +            assertTrue(m.containsKey(bis));
113 +        }
114 +        for (int i = 0; i < 1000; i++) {
115 +            assertTrue(m.containsKey(new ArrayList(Collections.singleton(new BI(i)))));
116 +        }
117 +    }
118 +
119 +    /**
120 +     * Elements of non-comparable classes equal to those of classes
121 +     * with erased generic type parameters based on Comparable can be
122 +     * inserted and found.
123 +     */
124 +    public void testGenericComparable2() {
125 +        ConcurrentHashMap<Object, Boolean> m = new ConcurrentHashMap<>();
126 +        for (int i = 0; i < 1000; i++) {
127 +            m.put(new ArrayList(Collections.singleton(new BI(i))), true);
128 +        }
129 +
130 +        for (int i = 0; i < 1000; i++) {
131 +            LexicographicList<BI> bis = new LexicographicList<BI>(new BI(i));
132 +            assertTrue(m.containsKey(bis));
133 +        }
134 +    }
135 +
136 +    /**
137 +     * getOrDefault returns value if present, else default
138 +     */
139 +    public void testGetOrDefault() {
140 +        ConcurrentHashMap map = map5();
141 +        assertEquals(map.getOrDefault(one, "Z"), "A");
142 +        assertEquals(map.getOrDefault(six, "Z"), "Z");
143 +    }
144 +
145      /**
146       * computeIfAbsent adds when the given key is not present
147       */
# Line 58 | Line 167 | public class ConcurrentHashMap8Test exte
167          map.computeIfAbsent(six, (x) -> null);
168          assertFalse(map.containsKey(six));
169      }
170 <    
170 >
171      /**
172       * computeIfPresent does not replace  if the key is already present
173       */
# Line 135 | Line 244 | public class ConcurrentHashMap8Test exte
244          assertFalse(map.containsKey(one));
245      }
246  
247 +    static Set<Integer> populatedSet(int n) {
248 +        Set<Integer> a = ConcurrentHashMap.<Integer>newKeySet();
249 +        assertTrue(a.isEmpty());
250 +        for (int i = 0; i < n; i++)
251 +            a.add(i);
252 +        assertFalse(a.isEmpty());
253 +        assertEquals(n, a.size());
254 +        return a;
255 +    }
256 +
257 +    static Set populatedSet(Integer[] elements) {
258 +        Set<Integer> a = ConcurrentHashMap.<Integer>newKeySet();
259 +        assertTrue(a.isEmpty());
260 +        for (int i = 0; i < elements.length; i++)
261 +            a.add(elements[i]);
262 +        assertFalse(a.isEmpty());
263 +        assertEquals(elements.length, a.size());
264 +        return a;
265 +    }
266 +
267 +    /**
268 +     * Default-constructed set is empty
269 +     */
270 +    public void testNewKeySet() {
271 +        Set a = ConcurrentHashMap.newKeySet();
272 +        assertTrue(a.isEmpty());
273 +    }
274 +
275 +    /**
276 +     * keySet.addAll adds each element from the given collection
277 +     */
278 +    public void testAddAll() {
279 +        Set full = populatedSet(3);
280 +        Vector v = new Vector();
281 +        v.add(three);
282 +        v.add(four);
283 +        v.add(five);
284 +        full.addAll(v);
285 +        assertEquals(6, full.size());
286 +    }
287 +
288 +    /**
289 +     * keySet.addAll adds each element from the given collection that did not
290 +     * already exist in the set
291 +     */
292 +    public void testAddAll2() {
293 +        Set full = populatedSet(3);
294 +        Vector v = new Vector();
295 +        v.add(three);
296 +        v.add(four);
297 +        v.add(one); // will not add this element
298 +        full.addAll(v);
299 +        assertEquals(5, full.size());
300 +    }
301 +
302 +    /**
303 +     * keySet.add will not add the element if it already exists in the set
304 +     */
305 +    public void testAdd2() {
306 +        Set full = populatedSet(3);
307 +        full.add(one);
308 +        assertEquals(3, full.size());
309 +    }
310 +
311 +    /**
312 +     * keySet.add adds the element when it does not exist in the set
313 +     */
314 +    public void testAdd3() {
315 +        Set full = populatedSet(3);
316 +        full.add(three);
317 +        assertTrue(full.contains(three));
318 +    }
319 +
320 +    /**
321 +     * keyset.clear removes all elements from the set
322 +     */
323 +    public void testClear() {
324 +        Set full = populatedSet(3);
325 +        full.clear();
326 +        assertEquals(0, full.size());
327 +    }
328 +
329 +    /**
330 +     * keyset.contains returns true for added elements
331 +     */
332 +    public void testContains() {
333 +        Set full = populatedSet(3);
334 +        assertTrue(full.contains(one));
335 +        assertFalse(full.contains(five));
336 +    }
337 +
338 +    /**
339 +     * KeySets with equal elements are equal
340 +     */
341 +    public void testEquals() {
342 +        Set a = populatedSet(3);
343 +        Set b = populatedSet(3);
344 +        assertTrue(a.equals(b));
345 +        assertTrue(b.equals(a));
346 +        assertEquals(a.hashCode(), b.hashCode());
347 +        a.add(m1);
348 +        assertFalse(a.equals(b));
349 +        assertFalse(b.equals(a));
350 +        b.add(m1);
351 +        assertTrue(a.equals(b));
352 +        assertTrue(b.equals(a));
353 +        assertEquals(a.hashCode(), b.hashCode());
354 +    }
355 +
356 +    /**
357 +     * KeySet.containsAll returns true for collections with subset of elements
358 +     */
359 +    public void testContainsAll() {
360 +        Set full = populatedSet(3);
361 +        Vector v = new Vector();
362 +        v.add(one);
363 +        v.add(two);
364 +        assertTrue(full.containsAll(v));
365 +        v.add(six);
366 +        assertFalse(full.containsAll(v));
367 +    }
368 +
369 +    /**
370 +     * KeySet.isEmpty is true when empty, else false
371 +     */
372 +    public void testIsEmpty() {
373 +        Set empty = ConcurrentHashMap.newKeySet();
374 +        Set full = populatedSet(3);
375 +        assertTrue(empty.isEmpty());
376 +        assertFalse(full.isEmpty());
377 +    }
378 +
379 +    /**
380 +     * KeySet.iterator() returns an iterator containing the elements of the
381 +     * set
382 +     */
383 +    public void testIterator() {
384 +        Collection empty = ConcurrentHashMap.newKeySet();
385 +        int size = 20;
386 +        assertFalse(empty.iterator().hasNext());
387 +        try {
388 +            empty.iterator().next();
389 +            shouldThrow();
390 +        } catch (NoSuchElementException success) {}
391 +
392 +        Integer[] elements = new Integer[size];
393 +        for (int i = 0; i < size; i++)
394 +            elements[i] = i;
395 +        Collections.shuffle(Arrays.asList(elements));
396 +        Collection<Integer> full = populatedSet(elements);
397 +
398 +        Iterator it = full.iterator();
399 +        for (int j = 0; j < size; j++) {
400 +            assertTrue(it.hasNext());
401 +            it.next();
402 +        }
403 +        assertFalse(it.hasNext());
404 +        try {
405 +            it.next();
406 +            shouldThrow();
407 +        } catch (NoSuchElementException success) {}
408 +    }
409 +
410 +    /**
411 +     * KeySet.iterator.remove removes current element
412 +     */
413 +    public void testIteratorRemove() {
414 +        Set q = populatedSet(3);
415 +        Iterator it = q.iterator();
416 +        Object removed = it.next();
417 +        it.remove();
418 +
419 +        it = q.iterator();
420 +        assertFalse(it.next().equals(removed));
421 +        assertFalse(it.next().equals(removed));
422 +        assertFalse(it.hasNext());
423 +    }
424 +
425 +    /**
426 +     * KeySet.toString holds toString of elements
427 +     */
428 +    public void testToString() {
429 +        assertEquals("[]", ConcurrentHashMap.newKeySet().toString());
430 +        Set full = populatedSet(3);
431 +        String s = full.toString();
432 +        for (int i = 0; i < 3; ++i)
433 +            assertTrue(s.contains(String.valueOf(i)));
434 +    }
435 +
436 +    /**
437 +     * KeySet.removeAll removes all elements from the given collection
438 +     */
439 +    public void testRemoveAll() {
440 +        Set full = populatedSet(3);
441 +        Vector v = new Vector();
442 +        v.add(one);
443 +        v.add(two);
444 +        full.removeAll(v);
445 +        assertEquals(1, full.size());
446 +    }
447 +
448 +    /**
449 +     * KeySet.remove removes an element
450 +     */
451 +    public void testRemove() {
452 +        Set full = populatedSet(3);
453 +        full.remove(one);
454 +        assertFalse(full.contains(one));
455 +        assertEquals(2, full.size());
456 +    }
457 +
458 +    /**
459 +     * keySet.size returns the number of elements
460 +     */
461 +    public void testSize() {
462 +        Set empty = ConcurrentHashMap.newKeySet();
463 +        Set full = populatedSet(3);
464 +        assertEquals(3, full.size());
465 +        assertEquals(0, empty.size());
466 +    }
467 +
468 +    /**
469 +     * KeySet.toArray() returns an Object array containing all elements from
470 +     * the set
471 +     */
472 +    public void testToArray() {
473 +        Object[] a = ConcurrentHashMap.newKeySet().toArray();
474 +        assertTrue(Arrays.equals(new Object[0], a));
475 +        assertSame(Object[].class, a.getClass());
476 +        int size = 20;
477 +        Integer[] elements = new Integer[size];
478 +        for (int i = 0; i < size; i++)
479 +            elements[i] = i;
480 +        Collections.shuffle(Arrays.asList(elements));
481 +        Collection<Integer> full = populatedSet(elements);
482 +
483 +        assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray())));
484 +        assertTrue(full.containsAll(Arrays.asList(full.toArray())));
485 +        assertSame(Object[].class, full.toArray().getClass());
486 +    }
487 +
488 +    /**
489 +     * toArray(Integer array) returns an Integer array containing all
490 +     * elements from the set
491 +     */
492 +    public void testToArray2() {
493 +        Collection empty = ConcurrentHashMap.newKeySet();
494 +        Integer[] a;
495 +        int size = 20;
496 +
497 +        a = new Integer[0];
498 +        assertSame(a, empty.toArray(a));
499 +
500 +        a = new Integer[size/2];
501 +        Arrays.fill(a, 42);
502 +        assertSame(a, empty.toArray(a));
503 +        assertNull(a[0]);
504 +        for (int i = 1; i < a.length; i++)
505 +            assertEquals(42, (int) a[i]);
506 +
507 +        Integer[] elements = new Integer[size];
508 +        for (int i = 0; i < size; i++)
509 +            elements[i] = i;
510 +        Collections.shuffle(Arrays.asList(elements));
511 +        Collection<Integer> full = populatedSet(elements);
512 +
513 +        Arrays.fill(a, 42);
514 +        assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray(a))));
515 +        for (int i = 0; i < a.length; i++)
516 +            assertEquals(42, (int) a[i]);
517 +        assertSame(Integer[].class, full.toArray(a).getClass());
518 +
519 +        a = new Integer[size];
520 +        Arrays.fill(a, 42);
521 +        assertSame(a, full.toArray(a));
522 +        assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray(a))));
523 +    }
524 +
525 +    /**
526 +     * A deserialized serialized set is equal
527 +     */
528 +    public void testSerialization() throws Exception {
529 +        int size = 20;
530 +        Set x = populatedSet(size);
531 +        Set y = serialClone(x);
532 +
533 +        assertTrue(x != y);
534 +        assertEquals(x.size(), y.size());
535 +        assertEquals(x.toString(), y.toString());
536 +        assertTrue(Arrays.equals(x.toArray(), y.toArray()));
537 +        assertEquals(x, y);
538 +        assertEquals(y, x);
539 +    }
540 +
541 +
542      static final int SIZE = 10000;
543      static ConcurrentHashMap<Long, Long> longMap;
544 <    
544 >
545      static ConcurrentHashMap<Long, Long> longMap() {
546          if (longMap == null) {
547              longMap = new ConcurrentHashMap<Long, Long>(SIZE);
# Line 147 | Line 551 | public class ConcurrentHashMap8Test exte
551          return longMap;
552      }
553  
554 +    // explicit function class to avoid type inference problems
555 +    static class AddKeys implements BiFunction<Map.Entry<Long,Long>, Map.Entry<Long,Long>, Map.Entry<Long,Long>> {
556 +        public Map.Entry<Long,Long> apply(Map.Entry<Long,Long> x, Map.Entry<Long,Long> y) {
557 +            return new AbstractMap.SimpleEntry<Long,Long>
558 +             (Long.valueOf(x.getKey().longValue() + y.getKey().longValue()),
559 +              Long.valueOf(1L));
560 +        }
561 +    }
562 +
563      /**
564 <     * forEachKeySequentially, forEachValueSequentially,
152 <     * forEachEntrySequentially, forEachSequentially,
153 <     * forEachKeyInParallel, forEachValueInParallel,
154 <     * forEachEntryInParallel, forEachInParallel traverse all keys,
155 <     * values, entries, or mappings accordingly
564 >     * forEachKeySequentially traverses all keys
565       */
566 <    public void testForEach() {
566 >    public void testForEachKeySequentially() {
567          LongAdder adder = new LongAdder();
568          ConcurrentHashMap<Long, Long> m = longMap();
569          m.forEachKeySequentially((Long x) -> adder.add(x.longValue()));
570          assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
571 <        adder.reset();
571 >    }
572 >
573 >    /**
574 >     * forEachValueSequentially traverses all values
575 >     */
576 >    public void testForEachValueSequentially() {
577 >        LongAdder adder = new LongAdder();
578 >        ConcurrentHashMap<Long, Long> m = longMap();
579          m.forEachValueSequentially((Long x) -> adder.add(x.longValue()));
580          assertEquals(adder.sum(), SIZE * (SIZE - 1));
581 <        adder.reset();
581 >    }
582 >
583 >    /**
584 >     * forEachSequentially traverses all mappings
585 >     */
586 >    public void testForEachSequentially() {
587 >        LongAdder adder = new LongAdder();
588 >        ConcurrentHashMap<Long, Long> m = longMap();
589          m.forEachSequentially((Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
590          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
591 <        adder.reset();
591 >    }
592 >
593 >    /**
594 >     * forEachEntrySequentially traverses all entries
595 >     */
596 >    public void testForEachEntrySequentially() {
597 >        LongAdder adder = new LongAdder();
598 >        ConcurrentHashMap<Long, Long> m = longMap();
599          m.forEachEntrySequentially((Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
600          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
601 <        adder.reset();
601 >    }
602 >
603 >    /**
604 >     * forEachKeyInParallel traverses all keys
605 >     */
606 >    public void testForEachKeyInParallel() {
607 >        LongAdder adder = new LongAdder();
608 >        ConcurrentHashMap<Long, Long> m = longMap();
609          m.forEachKeyInParallel((Long x) -> adder.add(x.longValue()));
610          assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
611 <        adder.reset();
611 >    }
612 >
613 >    /**
614 >     * forEachValueInParallel traverses all values
615 >     */
616 >    public void testForEachValueInParallel() {
617 >        LongAdder adder = new LongAdder();
618 >        ConcurrentHashMap<Long, Long> m = longMap();
619          m.forEachValueInParallel((Long x) -> adder.add(x.longValue()));
620          assertEquals(adder.sum(), SIZE * (SIZE - 1));
621 <        adder.reset();
621 >    }
622 >
623 >    /**
624 >     * forEachInParallel traverses all mappings
625 >     */
626 >    public void testForEachInParallel() {
627 >        LongAdder adder = new LongAdder();
628 >        ConcurrentHashMap<Long, Long> m = longMap();
629          m.forEachInParallel((Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
630          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
631 <        adder.reset();
631 >    }
632 >
633 >    /**
634 >     * forEachEntryInParallel traverses all entries
635 >     */
636 >    public void testForEachEntryInParallel() {
637 >        LongAdder adder = new LongAdder();
638 >        ConcurrentHashMap<Long, Long> m = longMap();
639          m.forEachEntryInParallel((Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
640          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
641      }
642  
643      /**
644 <     * Mapped forEachKeySequentially, forEachValueSequentially,
645 <     * forEachEntrySequentially, forEachSequentially,
188 <     * forEachKeyInParallel, forEachValueInParallel,
189 <     * forEachEntryInParallel, forEachInParallel traverse the given
190 <     * transformations of all keys, values, entries, or mappings
191 <     * accordingly
644 >     * Mapped forEachKeySequentially traverses the given
645 >     * transformations of all keys
646       */
647 <    public void testMappedForEach() {
647 >    public void testMappedForEachKeySequentially() {
648          LongAdder adder = new LongAdder();
649          ConcurrentHashMap<Long, Long> m = longMap();
650          m.forEachKeySequentially((Long x) -> Long.valueOf(4 * x.longValue()),
651                                   (Long x) -> adder.add(x.longValue()));
652          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
653 <        adder.reset();
653 >    }
654 >
655 >    /**
656 >     * Mapped forEachValueSequentially traverses the given
657 >     * transformations of all values
658 >     */
659 >    public void testMappedForEachValueSequentially() {
660 >        LongAdder adder = new LongAdder();
661 >        ConcurrentHashMap<Long, Long> m = longMap();
662          m.forEachValueSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
663                                     (Long x) -> adder.add(x.longValue()));
664          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
665 <        adder.reset();
665 >    }
666 >
667 >    /**
668 >     * Mapped forEachSequentially traverses the given
669 >     * transformations of all mappings
670 >     */
671 >    public void testMappedForEachSequentially() {
672 >        LongAdder adder = new LongAdder();
673 >        ConcurrentHashMap<Long, Long> m = longMap();
674          m.forEachSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
675                                (Long x) -> adder.add(x.longValue()));
676          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
677 <        adder.reset();
677 >    }
678 >
679 >    /**
680 >     * Mapped forEachEntrySequentially traverses the given
681 >     * transformations of all entries
682 >     */
683 >    public void testMappedForEachEntrySequentially() {
684 >        LongAdder adder = new LongAdder();
685 >        ConcurrentHashMap<Long, Long> m = longMap();
686          m.forEachEntrySequentially((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
687                                     (Long x) -> adder.add(x.longValue()));
688          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
689 <        adder.reset();
689 >    }
690 >
691 >    /**
692 >     * Mapped forEachKeyInParallel traverses the given
693 >     * transformations of all keys
694 >     */
695 >    public void testMappedForEachKeyInParallel() {
696 >        LongAdder adder = new LongAdder();
697 >        ConcurrentHashMap<Long, Long> m = longMap();
698          m.forEachKeyInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
699                                 (Long x) -> adder.add(x.longValue()));
700          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
701 <        adder.reset();
701 >    }
702 >
703 >    /**
704 >     * Mapped forEachValueInParallel traverses the given
705 >     * transformations of all values
706 >     */
707 >    public void testMappedForEachValueInParallel() {
708 >        LongAdder adder = new LongAdder();
709 >        ConcurrentHashMap<Long, Long> m = longMap();
710          m.forEachValueInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
711                                   (Long x) -> adder.add(x.longValue()));
712          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
713 <        adder.reset();
713 >    }
714 >
715 >    /**
716 >     * Mapped forEachInParallel traverses the given
717 >     * transformations of all mappings
718 >     */
719 >    public void testMappedForEachInParallel() {
720 >        LongAdder adder = new LongAdder();
721 >        ConcurrentHashMap<Long, Long> m = longMap();
722          m.forEachInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
723                              (Long x) -> adder.add(x.longValue()));
724          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
725 <        adder.reset();
725 >    }
726 >
727 >    /**
728 >     * Mapped forEachEntryInParallel traverses the given
729 >     * transformations of all entries
730 >     */
731 >    public void testMappedForEachEntryInParallel() {
732 >        LongAdder adder = new LongAdder();
733 >        ConcurrentHashMap<Long, Long> m = longMap();
734          m.forEachEntryInParallel((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
735                                   (Long x) -> adder.add(x.longValue()));
736          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
737      }
738  
739 +
740      /**
741 <     * reduceKeysSequentially, reduceValuesSequentially,
231 <     * reduceSequentially, reduceEntriesSequentially,
232 <     * reduceKeysInParallel, reduceValuesInParallel, reduceInParallel,
233 <     * and reduceEntriesInParallel, accumulate across all keys,
234 <     * values, entries, or mappings accordingly
741 >     * reduceKeysSequentially accumulates across all keys,
742       */
743 <    public void testReduce() {
743 >    public void testReduceKeysSequentially() {
744          ConcurrentHashMap<Long, Long> m = longMap();
745          Long r;
746          r = m.reduceKeysSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
747          assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
748 <        r = m.reduceValuesSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
749 <        assertEquals((long)r, (long)SIZE * (SIZE - 1));
750 <        r = m.reduceSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
751 <                                 (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
752 <        
753 <        assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
754 <        r = m.reduceEntriesSequentially((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
755 <                                        (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
756 <        assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
748 >    }
749 >
750 >    /**
751 >     * reduceValuesSequentially accumulates across all values
752 >     */
753 >    public void testReduceValuesSequentially() {
754 >        ConcurrentHashMap<Long, Long> m = longMap();
755 >        Long r;
756 >        r = m.reduceKeysSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
757 >        assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
758 >    }
759 >
760  
761 +    /**
762 +     * reduceEntriesSequentially accumulates across all entries
763 +     */
764 +    public void testReduceEntriesSequentially() {
765 +        ConcurrentHashMap<Long, Long> m = longMap();
766 +        Map.Entry<Long,Long> r;
767 +        r = m.reduceEntriesSequentially(new AddKeys());
768 +        assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2);
769 +    }
770 +
771 +    /**
772 +     * reduceKeysInParallel accumulates across all keys
773 +     */
774 +    public void testReduceKeysInParallel() {
775 +        ConcurrentHashMap<Long, Long> m = longMap();
776 +        Long r;
777          r = m.reduceKeysInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
778          assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
779 +    }
780 +
781 +    /**
782 +     * reduceValuesInParallel accumulates across all values
783 +     */
784 +    public void testReduceValuesInParallel() {
785 +        ConcurrentHashMap<Long, Long> m = longMap();
786 +        Long r;
787          r = m.reduceValuesInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
788          assertEquals((long)r, (long)SIZE * (SIZE - 1));
789 +    }
790 +
791 +    /**
792 +     * reduceEntriesInParallel accumulate across all entries
793 +     */
794 +    public void testReduceEntriesInParallel() {
795 +        ConcurrentHashMap<Long, Long> m = longMap();
796 +        Map.Entry<Long,Long> r;
797 +        r = m.reduceEntriesInParallel(new AddKeys());
798 +        assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2);
799 +    }
800 +
801 +    /**
802 +     * Mapped reduceKeysSequentially accumulates mapped keys
803 +     */
804 +    public void testMapReduceKeysSequentially() {
805 +        ConcurrentHashMap<Long, Long> m = longMap();
806 +        Long r = m.reduceKeysSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
807 +                                     (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
808 +        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
809 +    }
810 +
811 +    /**
812 +     * Mapped reduceValuesSequentially accumulates mapped values
813 +     */
814 +    public void testMapReduceValuesSequentially() {
815 +        ConcurrentHashMap<Long, Long> m = longMap();
816 +        Long r = m.reduceValuesSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
817 +                                       (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
818 +        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
819 +    }
820 +
821 +    /**
822 +     * reduceSequentially accumulates across all transformed mappings
823 +     */
824 +    public void testMappedReduceSequentially() {
825 +        ConcurrentHashMap<Long, Long> m = longMap();
826 +        Long r = m.reduceSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
827 +                                 (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
828 +
829 +        assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
830 +    }
831 +
832 +    /**
833 +     * Mapped reduceKeysInParallel, accumulates mapped keys
834 +     */
835 +    public void testMapReduceKeysInParallel() {
836 +        ConcurrentHashMap<Long, Long> m = longMap();
837 +        Long r = m.reduceKeysInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
838 +                                   (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
839 +        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
840 +    }
841 +
842 +    /**
843 +     * Mapped reduceValuesInParallel accumulates mapped values
844 +     */
845 +    public void testMapReduceValuesInParallel() {
846 +        ConcurrentHashMap<Long, Long> m = longMap();
847 +        Long r = m.reduceValuesInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
848 +                                     (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
849 +        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
850 +    }
851 +
852 +    /**
853 +     * reduceInParallel accumulate across all transformed mappings
854 +     */
855 +    public void testMappedReduceInParallel() {
856 +        ConcurrentHashMap<Long, Long> m = longMap();
857 +        Long r;
858          r = m.reduceInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
859                                 (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
860          assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
258        r = m.reduceEntriesInParallel((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
259                                        (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
260        assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
861      }
862  
863 <    /*
864 <     * Mapped reduceKeysSequentially, reduceKeysToIntSequentially,
865 <     * reduceKeysToLongSequentially, reduceKeysToDoubleSequentially,
266 <     * reduceValuesSequentially, reduceValuesToLongSequentially,
267 <     * reduceValuesToDoubleSequentially, reduceKeysInParallel,
268 <     * reduceKeysToLongInParallel, reduceKeysToIntInParallel,
269 <     * reduceKeysToDoubleInParallel, reduceValuesInParallel,
270 <     * reduceValuesToLongInParallel, reduceValuesToIntInParallel,
271 <     * reduceValuesToDoubleInParallel accumulate mapped keys, values,
272 <     * entries, or mappings accordingly
863 >
864 >    /**
865 >     * reduceKeysToLongSequentially accumulates mapped keys
866       */
867 <    public void testMapReduce() {
867 >    public void testReduceKeysToLongSequentially() {
868          ConcurrentHashMap<Long, Long> m = longMap();
869 <        Long r; long lr; int ir; double dr;
277 <        r = m.reduceKeysSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
278 <                                     (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
279 <        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
280 <        lr = m.reduceKeysToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum);
869 >        long lr = m.reduceKeysToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum);
870          assertEquals(lr, (long)SIZE * (SIZE - 1) / 2);
871 +    }
872 +
873 +    /**
874 +     * reduceKeysToIntSequentially accumulates mapped keys
875 +     */
876 +    public void testReduceKeysToIntSequentially() {
877 +        ConcurrentHashMap<Long, Long> m = longMap();
878 +        int ir = m.reduceKeysToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum);
879 +        assertEquals(ir, SIZE * (SIZE - 1) / 2);
880 +    }
881  
882 <        ir = m.reduceKeysToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum);
883 <        assertEquals(ir, (int)SIZE * (SIZE - 1) / 2);
884 <        dr = m.reduceKeysToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum);
882 >    /**
883 >     * reduceKeysToDoubleSequentially accumulates mapped keys
884 >     */
885 >    public void testReduceKeysToDoubleSequentially() {
886 >        ConcurrentHashMap<Long, Long> m = longMap();
887 >        double dr = m.reduceKeysToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum);
888          assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
889 +    }
890  
891 <        r = m.reduceValuesSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
892 <                                       (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
893 <        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
894 <        lr = m.reduceValuesToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum);
891 >    /**
892 >     * reduceValuesToLongSequentially accumulates mapped values
893 >     */
894 >    public void testReduceValuesToLongSequentially() {
895 >        ConcurrentHashMap<Long, Long> m = longMap();
896 >        long lr = m.reduceValuesToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum);
897          assertEquals(lr, (long)SIZE * (SIZE - 1));
898 <        ir = m.reduceValuesToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum);
294 <        assertEquals(ir, (int)SIZE * (SIZE - 1));
898 >    }
899  
900 <        dr = m.reduceValuesToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum);
900 >    /**
901 >     * reduceValuesToIntSequentially accumulates mapped values
902 >     */
903 >    public void testReduceValuesToIntSequentially() {
904 >        ConcurrentHashMap<Long, Long> m = longMap();
905 >        int ir = m.reduceValuesToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum);
906 >        assertEquals(ir, SIZE * (SIZE - 1));
907 >    }
908 >
909 >    /**
910 >     * reduceValuesToDoubleSequentially accumulates mapped values
911 >     */
912 >    public void testReduceValuesToDoubleSequentially() {
913 >        ConcurrentHashMap<Long, Long> m = longMap();
914 >        double dr = m.reduceValuesToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum);
915          assertEquals(dr, (double)SIZE * (SIZE - 1));
916 +    }
917  
918 <        r = m.reduceKeysInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
919 <                                   (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
920 <        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
921 <        lr = m.reduceKeysToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum);
918 >    /**
919 >     * reduceKeysToLongInParallel accumulates mapped keys
920 >     */
921 >    public void testReduceKeysToLongInParallel() {
922 >        ConcurrentHashMap<Long, Long> m = longMap();
923 >        long lr = m.reduceKeysToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum);
924          assertEquals(lr, (long)SIZE * (SIZE - 1) / 2);
925 <        ir = m.reduceKeysToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum);
926 <        assertEquals(ir, (int)SIZE * (SIZE - 1) / 2);
927 <        dr = m.reduceKeysToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum);
925 >    }
926 >
927 >    /**
928 >     * reduceKeysToIntInParallel accumulates mapped keys
929 >     */
930 >    public void testReduceKeysToIntInParallel() {
931 >        ConcurrentHashMap<Long, Long> m = longMap();
932 >        int ir = m.reduceKeysToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum);
933 >        assertEquals(ir, SIZE * (SIZE - 1) / 2);
934 >    }
935 >
936 >    /**
937 >     * reduceKeysToDoubleInParallel accumulates mapped values
938 >     */
939 >    public void testReduceKeysToDoubleInParallel() {
940 >        ConcurrentHashMap<Long, Long> m = longMap();
941 >        double dr = m.reduceKeysToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum);
942          assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
943 +    }
944  
945 <        r = m.reduceValuesInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
946 <                                     (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
947 <        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
948 <        lr = m.reduceValuesToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum);
945 >    /**
946 >     * reduceValuesToLongInParallel accumulates mapped values
947 >     */
948 >    public void testReduceValuesToLongInParallel() {
949 >        ConcurrentHashMap<Long, Long> m = longMap();
950 >        long lr = m.reduceValuesToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum);
951          assertEquals(lr, (long)SIZE * (SIZE - 1));
952 <        ir = m.reduceValuesToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum);
953 <        assertEquals(ir, (int)SIZE * (SIZE - 1));
954 <        dr = m.reduceValuesToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum);
952 >    }
953 >
954 >    /**
955 >     * reduceValuesToIntInParallel accumulates mapped values
956 >     */
957 >    public void testReduceValuesToIntInParallel() {
958 >        ConcurrentHashMap<Long, Long> m = longMap();
959 >        int ir = m.reduceValuesToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum);
960 >        assertEquals(ir, SIZE * (SIZE - 1));
961 >    }
962 >
963 >    /**
964 >     * reduceValuesToDoubleInParallel accumulates mapped values
965 >     */
966 >    public void testReduceValuesToDoubleInParallel() {
967 >        ConcurrentHashMap<Long, Long> m = longMap();
968 >        double dr = m.reduceValuesToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum);
969          assertEquals(dr, (double)SIZE * (SIZE - 1));
970      }
971  
972      /**
973 <     * searchKeysSequentially, searchValuesSequentially,
974 <     * searchSequentially, searchEntriesSequentially,
323 <     * searchKeysInParallel, searchValuesInParallel, searchInParallel,
324 <     * searchEntriesInParallel all return a non-null result of search
325 <     * function, or null if none, across keys, values, entries, or
326 <     * mappings accordingly
973 >     * searchKeysSequentially returns a non-null result of search
974 >     * function, or null if none
975       */
976 <    public void testSearch() {
976 >    public void testSearchKeysSequentially() {
977          ConcurrentHashMap<Long, Long> m = longMap();
978          Long r;
979 <        r = m.searchKeysSequentially((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
979 >        r = m.searchKeysSequentially((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
980          assertEquals((long)r, (long)(SIZE/2));
981 +        r = m.searchKeysSequentially((Long x) -> x.longValue() < 0L ? x : null);
982 +        assertNull(r);
983 +    }
984 +
985 +    /**
986 +     * searchValuesSequentially returns a non-null result of search
987 +     * function, or null if none
988 +     */
989 +    public void testSearchValuesSequentially() {
990 +        ConcurrentHashMap<Long, Long> m = longMap();
991 +        Long r;
992          r = m.searchValuesSequentially((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
993          assertEquals((long)r, (long)(SIZE/2));
994 <        r = m.searchSequentially((Long x, Long y) -> x.longValue() == (long)(SIZE/2)? x : null);
336 <        assertEquals((long)r, (long)(SIZE/2));
337 <        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null);
338 <        assertEquals((long)r, (long)(SIZE/2));
339 <
340 <        r = m.searchKeysSequentially((Long x) -> x.longValue() < 0L? x : null);
341 <        assertNull(r);
342 <        r = m.searchValuesSequentially((Long x) -> x.longValue() < 0L? x : null);
343 <        assertNull(r);
344 <        r = m.searchSequentially((Long x, Long y) -> x.longValue() < 0L? x : null);
345 <        assertNull(r);
346 <        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L? e.getKey() : null);
994 >        r = m.searchValuesSequentially((Long x) -> x.longValue() < 0L ? x : null);
995          assertNull(r);
996 +    }
997  
998 <        r = m.searchKeysInParallel((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
999 <        assertEquals((long)r, (long)(SIZE/2));
1000 <        r = m.searchValuesInParallel((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
1001 <        assertEquals((long)r, (long)(SIZE/2));
1002 <        r = m.searchInParallel((Long x, Long y) -> x.longValue() == (long)(SIZE/2)? x : null);
998 >    /**
999 >     * searchSequentially returns a non-null result of search
1000 >     * function, or null if none
1001 >     */
1002 >    public void testSearchSequentially() {
1003 >        ConcurrentHashMap<Long, Long> m = longMap();
1004 >        Long r;
1005 >        r = m.searchSequentially((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
1006          assertEquals((long)r, (long)(SIZE/2));
1007 <        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null);
1007 >        r = m.searchSequentially((Long x, Long y) -> x.longValue() < 0L ? x : null);
1008 >        assertNull(r);
1009 >    }
1010 >
1011 >    /**
1012 >     * searchEntriesSequentially returns a non-null result of search
1013 >     * function, or null if none
1014 >     */
1015 >    public void testSearchEntriesSequentially() {
1016 >        ConcurrentHashMap<Long, Long> m = longMap();
1017 >        Long r;
1018 >        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
1019          assertEquals((long)r, (long)(SIZE/2));
1020 +        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
1021 +        assertNull(r);
1022 +    }
1023  
1024 <        r = m.searchKeysInParallel((Long x) -> x.longValue() < 0L? x : null);
1024 >    /**
1025 >     * searchKeysInParallel returns a non-null result of search
1026 >     * function, or null if none
1027 >     */
1028 >    public void testSearchKeysInParallel() {
1029 >        ConcurrentHashMap<Long, Long> m = longMap();
1030 >        Long r;
1031 >        r = m.searchKeysInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
1032 >        assertEquals((long)r, (long)(SIZE/2));
1033 >        r = m.searchKeysInParallel((Long x) -> x.longValue() < 0L ? x : null);
1034          assertNull(r);
1035 <        r = m.searchValuesInParallel((Long x) -> x.longValue() < 0L? x : null);
1035 >    }
1036 >
1037 >    /**
1038 >     * searchValuesInParallel returns a non-null result of search
1039 >     * function, or null if none
1040 >     */
1041 >    public void testSearchValuesInParallel() {
1042 >        ConcurrentHashMap<Long, Long> m = longMap();
1043 >        Long r;
1044 >        r = m.searchValuesInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
1045 >        assertEquals((long)r, (long)(SIZE/2));
1046 >        r = m.searchValuesInParallel((Long x) -> x.longValue() < 0L ? x : null);
1047          assertNull(r);
1048 <        r = m.searchInParallel((Long x, Long y) -> x.longValue() < 0L? x : null);
1048 >    }
1049 >
1050 >    /**
1051 >     * searchInParallel returns a non-null result of search function,
1052 >     * or null if none
1053 >     */
1054 >    public void testSearchInParallel() {
1055 >        ConcurrentHashMap<Long, Long> m = longMap();
1056 >        Long r;
1057 >        r = m.searchInParallel((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
1058 >        assertEquals((long)r, (long)(SIZE/2));
1059 >        r = m.searchInParallel((Long x, Long y) -> x.longValue() < 0L ? x : null);
1060          assertNull(r);
1061 <        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L? e.getKey() : null);
1061 >    }
1062 >
1063 >    /**
1064 >     * searchEntriesInParallel returns a non-null result of search
1065 >     * function, or null if none
1066 >     */
1067 >    public void testSearchEntriesInParallel() {
1068 >        ConcurrentHashMap<Long, Long> m = longMap();
1069 >        Long r;
1070 >        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
1071 >        assertEquals((long)r, (long)(SIZE/2));
1072 >        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
1073          assertNull(r);
1074      }
1075  
# Line 385 | Line 1093 | public class ConcurrentHashMap8Test exte
1093          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
1094          adder.reset();
1095          ConcurrentHashMap.ForkJoinTasks.forEachEntry
1096 <            (m,
1096 >            (m,
1097               (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())).invoke();
1098          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
1099          adder.reset();
# Line 434 | Line 1142 | public class ConcurrentHashMap8Test exte
1142          assertEquals(lr, (long)SIZE * (SIZE - 1) / 2);
1143          ir = ConcurrentHashMap.ForkJoinTasks.reduceKeysToInt
1144              (m, (Long x) -> x.intValue(), 0, Integer::sum).invoke();
1145 <        assertEquals(ir, (int)SIZE * (SIZE - 1) / 2);
1145 >        assertEquals(ir, SIZE * (SIZE - 1) / 2);
1146          dr = ConcurrentHashMap.ForkJoinTasks.reduceKeysToDouble
1147              (m, (Long x) -> x.doubleValue(), 0.0, Double::sum).invoke();
1148          assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
# Line 447 | Line 1155 | public class ConcurrentHashMap8Test exte
1155          assertEquals(lr, (long)SIZE * (SIZE - 1));
1156          ir = ConcurrentHashMap.ForkJoinTasks.reduceValuesToInt
1157              (m, (Long x) -> x.intValue(), 0, Integer::sum).invoke();
1158 <        assertEquals(ir, (int)SIZE * (SIZE - 1));
1158 >        assertEquals(ir, SIZE * (SIZE - 1));
1159          dr = ConcurrentHashMap.ForkJoinTasks.reduceValuesToDouble
1160              (m, (Long x) -> x.doubleValue(), 0.0, Double::sum).invoke();
1161          assertEquals(dr, (double)SIZE * (SIZE - 1));
# Line 463 | Line 1171 | public class ConcurrentHashMap8Test exte
1171          r = ConcurrentHashMap.ForkJoinTasks.searchEntries
1172              (m, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null).invoke();
1173          assertEquals((long)r, (long)(SIZE/2));
1174 <    }            
1174 >    }
1175   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines