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.8 by jsr166, Thu Apr 11 20:03:44 2013 UTC vs.
Revision 1.9 by dl, Tue May 21 19:11:16 2013 UTC

# Line 467 | Line 467 | public class ConcurrentHashMap8Test exte
467      public void testForEachKeySequentially() {
468          LongAdder adder = new LongAdder();
469          ConcurrentHashMap<Long, Long> m = longMap();
470 <        m.forEachKeySequentially((Long x) -> adder.add(x.longValue()));
470 >        m.forEachKey(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
471          assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
472      }
473  
# Line 477 | Line 477 | public class ConcurrentHashMap8Test exte
477      public void testForEachValueSequentially() {
478          LongAdder adder = new LongAdder();
479          ConcurrentHashMap<Long, Long> m = longMap();
480 <        m.forEachValueSequentially((Long x) -> adder.add(x.longValue()));
480 >        m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
481          assertEquals(adder.sum(), SIZE * (SIZE - 1));
482      }
483  
# Line 487 | Line 487 | public class ConcurrentHashMap8Test exte
487      public void testForEachSequentially() {
488          LongAdder adder = new LongAdder();
489          ConcurrentHashMap<Long, Long> m = longMap();
490 <        m.forEachSequentially((Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
490 >        m.forEach(Long.MAX_VALUE, (Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
491          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
492      }
493  
# Line 497 | Line 497 | public class ConcurrentHashMap8Test exte
497      public void testForEachEntrySequentially() {
498          LongAdder adder = new LongAdder();
499          ConcurrentHashMap<Long, Long> m = longMap();
500 <        m.forEachEntrySequentially((Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
500 >        m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
501          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
502      }
503  
# Line 507 | Line 507 | public class ConcurrentHashMap8Test exte
507      public void testForEachKeyInParallel() {
508          LongAdder adder = new LongAdder();
509          ConcurrentHashMap<Long, Long> m = longMap();
510 <        m.forEachKeyInParallel((Long x) -> adder.add(x.longValue()));
510 >        m.forEachKey(1L, (Long x) -> adder.add(x.longValue()));
511          assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
512      }
513  
# Line 517 | Line 517 | public class ConcurrentHashMap8Test exte
517      public void testForEachValueInParallel() {
518          LongAdder adder = new LongAdder();
519          ConcurrentHashMap<Long, Long> m = longMap();
520 <        m.forEachValueInParallel((Long x) -> adder.add(x.longValue()));
520 >        m.forEachValue(1L, (Long x) -> adder.add(x.longValue()));
521          assertEquals(adder.sum(), SIZE * (SIZE - 1));
522      }
523  
# Line 527 | Line 527 | public class ConcurrentHashMap8Test exte
527      public void testForEachInParallel() {
528          LongAdder adder = new LongAdder();
529          ConcurrentHashMap<Long, Long> m = longMap();
530 <        m.forEachInParallel((Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
530 >        m.forEach(1L, (Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
531          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
532      }
533  
# Line 537 | Line 537 | public class ConcurrentHashMap8Test exte
537      public void testForEachEntryInParallel() {
538          LongAdder adder = new LongAdder();
539          ConcurrentHashMap<Long, Long> m = longMap();
540 <        m.forEachEntryInParallel((Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
540 >        m.forEachEntry(1L, (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
541          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
542      }
543  
# Line 548 | Line 548 | public class ConcurrentHashMap8Test exte
548      public void testMappedForEachKeySequentially() {
549          LongAdder adder = new LongAdder();
550          ConcurrentHashMap<Long, Long> m = longMap();
551 <        m.forEachKeySequentially((Long x) -> Long.valueOf(4 * x.longValue()),
551 >        m.forEachKey(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()),
552                                   (Long x) -> adder.add(x.longValue()));
553          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
554      }
# Line 560 | Line 560 | public class ConcurrentHashMap8Test exte
560      public void testMappedForEachValueSequentially() {
561          LongAdder adder = new LongAdder();
562          ConcurrentHashMap<Long, Long> m = longMap();
563 <        m.forEachValueSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
563 >        m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()),
564                                     (Long x) -> adder.add(x.longValue()));
565          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
566      }
# Line 572 | Line 572 | public class ConcurrentHashMap8Test exte
572      public void testMappedForEachSequentially() {
573          LongAdder adder = new LongAdder();
574          ConcurrentHashMap<Long, Long> m = longMap();
575 <        m.forEachSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
575 >        m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
576                                (Long x) -> adder.add(x.longValue()));
577          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
578      }
# Line 584 | Line 584 | public class ConcurrentHashMap8Test exte
584      public void testMappedForEachEntrySequentially() {
585          LongAdder adder = new LongAdder();
586          ConcurrentHashMap<Long, Long> m = longMap();
587 <        m.forEachEntrySequentially((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
587 >        m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
588                                     (Long x) -> adder.add(x.longValue()));
589          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
590      }
# Line 596 | Line 596 | public class ConcurrentHashMap8Test exte
596      public void testMappedForEachKeyInParallel() {
597          LongAdder adder = new LongAdder();
598          ConcurrentHashMap<Long, Long> m = longMap();
599 <        m.forEachKeyInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
599 >        m.forEachKey(1L, (Long x) -> Long.valueOf(4 * x.longValue()),
600                                 (Long x) -> adder.add(x.longValue()));
601          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
602      }
# Line 608 | Line 608 | public class ConcurrentHashMap8Test exte
608      public void testMappedForEachValueInParallel() {
609          LongAdder adder = new LongAdder();
610          ConcurrentHashMap<Long, Long> m = longMap();
611 <        m.forEachValueInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
611 >        m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()),
612                                   (Long x) -> adder.add(x.longValue()));
613          assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
614      }
# Line 620 | Line 620 | public class ConcurrentHashMap8Test exte
620      public void testMappedForEachInParallel() {
621          LongAdder adder = new LongAdder();
622          ConcurrentHashMap<Long, Long> m = longMap();
623 <        m.forEachInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
623 >        m.forEach(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
624                              (Long x) -> adder.add(x.longValue()));
625          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
626      }
# Line 632 | Line 632 | public class ConcurrentHashMap8Test exte
632      public void testMappedForEachEntryInParallel() {
633          LongAdder adder = new LongAdder();
634          ConcurrentHashMap<Long, Long> m = longMap();
635 <        m.forEachEntryInParallel((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
635 >        m.forEachEntry(1L, (Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
636                                   (Long x) -> adder.add(x.longValue()));
637          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
638      }
# Line 644 | Line 644 | public class ConcurrentHashMap8Test exte
644      public void testReduceKeysSequentially() {
645          ConcurrentHashMap<Long, Long> m = longMap();
646          Long r;
647 <        r = m.reduceKeysSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
647 >        r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
648          assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
649      }
650  
# Line 654 | Line 654 | public class ConcurrentHashMap8Test exte
654      public void testReduceValuesSequentially() {
655          ConcurrentHashMap<Long, Long> m = longMap();
656          Long r;
657 <        r = m.reduceKeysSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
657 >        r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
658          assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
659      }
660  
# Line 665 | Line 665 | public class ConcurrentHashMap8Test exte
665      public void testReduceEntriesSequentially() {
666          ConcurrentHashMap<Long, Long> m = longMap();
667          Map.Entry<Long,Long> r;
668 <        r = m.reduceEntriesSequentially(new AddKeys());
668 >        r = m.reduceEntries(Long.MAX_VALUE, new AddKeys());
669          assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2);
670      }
671  
# Line 675 | Line 675 | public class ConcurrentHashMap8Test exte
675      public void testReduceKeysInParallel() {
676          ConcurrentHashMap<Long, Long> m = longMap();
677          Long r;
678 <        r = m.reduceKeysInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
678 >        r = m.reduceKeys(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
679          assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
680      }
681  
# Line 685 | Line 685 | public class ConcurrentHashMap8Test exte
685      public void testReduceValuesInParallel() {
686          ConcurrentHashMap<Long, Long> m = longMap();
687          Long r;
688 <        r = m.reduceValuesInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
688 >        r = m.reduceValues(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
689          assertEquals((long)r, (long)SIZE * (SIZE - 1));
690      }
691  
# Line 695 | Line 695 | public class ConcurrentHashMap8Test exte
695      public void testReduceEntriesInParallel() {
696          ConcurrentHashMap<Long, Long> m = longMap();
697          Map.Entry<Long,Long> r;
698 <        r = m.reduceEntriesInParallel(new AddKeys());
698 >        r = m.reduceEntries(1L, new AddKeys());
699          assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2);
700      }
701  
# Line 704 | Line 704 | public class ConcurrentHashMap8Test exte
704       */
705      public void testMapReduceKeysSequentially() {
706          ConcurrentHashMap<Long, Long> m = longMap();
707 <        Long r = m.reduceKeysSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
707 >        Long r = m.reduceKeys(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()),
708                                       (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
709          assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
710      }
# Line 714 | Line 714 | public class ConcurrentHashMap8Test exte
714       */
715      public void testMapReduceValuesSequentially() {
716          ConcurrentHashMap<Long, Long> m = longMap();
717 <        Long r = m.reduceValuesSequentially((Long x) -> Long.valueOf(4 * x.longValue()),
717 >        Long r = m.reduceValues(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()),
718                                         (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
719          assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
720      }
# Line 724 | Line 724 | public class ConcurrentHashMap8Test exte
724       */
725      public void testMappedReduceSequentially() {
726          ConcurrentHashMap<Long, Long> m = longMap();
727 <        Long r = m.reduceSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
727 >        Long r = m.reduce(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
728                                   (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
729  
730          assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
# Line 735 | Line 735 | public class ConcurrentHashMap8Test exte
735       */
736      public void testMapReduceKeysInParallel() {
737          ConcurrentHashMap<Long, Long> m = longMap();
738 <        Long r = m.reduceKeysInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
738 >        Long r = m.reduceKeys(1L, (Long x) -> Long.valueOf(4 * x.longValue()),
739                                     (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
740          assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
741      }
# Line 745 | Line 745 | public class ConcurrentHashMap8Test exte
745       */
746      public void testMapReduceValuesInParallel() {
747          ConcurrentHashMap<Long, Long> m = longMap();
748 <        Long r = m.reduceValuesInParallel((Long x) -> Long.valueOf(4 * x.longValue()),
748 >        Long r = m.reduceValues(1L, (Long x) -> Long.valueOf(4 * x.longValue()),
749                                       (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
750          assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
751      }
# Line 756 | Line 756 | public class ConcurrentHashMap8Test exte
756      public void testMappedReduceInParallel() {
757          ConcurrentHashMap<Long, Long> m = longMap();
758          Long r;
759 <        r = m.reduceInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
759 >        r = m.reduce(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
760                                 (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
761          assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
762      }
# Line 767 | Line 767 | public class ConcurrentHashMap8Test exte
767       */
768      public void testReduceKeysToLongSequentially() {
769          ConcurrentHashMap<Long, Long> m = longMap();
770 <        long lr = m.reduceKeysToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum);
770 >        long lr = m.reduceKeysToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum);
771          assertEquals(lr, (long)SIZE * (SIZE - 1) / 2);
772      }
773  
# Line 776 | Line 776 | public class ConcurrentHashMap8Test exte
776       */
777      public void testReduceKeysToIntSequentially() {
778          ConcurrentHashMap<Long, Long> m = longMap();
779 <        int ir = m.reduceKeysToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum);
779 >        int ir = m.reduceKeysToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum);
780          assertEquals(ir, SIZE * (SIZE - 1) / 2);
781      }
782  
# Line 785 | Line 785 | public class ConcurrentHashMap8Test exte
785       */
786      public void testReduceKeysToDoubleSequentially() {
787          ConcurrentHashMap<Long, Long> m = longMap();
788 <        double dr = m.reduceKeysToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum);
788 >        double dr = m.reduceKeysToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum);
789          assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
790      }
791  
# Line 794 | Line 794 | public class ConcurrentHashMap8Test exte
794       */
795      public void testReduceValuesToLongSequentially() {
796          ConcurrentHashMap<Long, Long> m = longMap();
797 <        long lr = m.reduceValuesToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum);
797 >        long lr = m.reduceValuesToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum);
798          assertEquals(lr, (long)SIZE * (SIZE - 1));
799      }
800  
# Line 803 | Line 803 | public class ConcurrentHashMap8Test exte
803       */
804      public void testReduceValuesToIntSequentially() {
805          ConcurrentHashMap<Long, Long> m = longMap();
806 <        int ir = m.reduceValuesToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum);
806 >        int ir = m.reduceValuesToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum);
807          assertEquals(ir, SIZE * (SIZE - 1));
808      }
809  
# Line 812 | Line 812 | public class ConcurrentHashMap8Test exte
812       */
813      public void testReduceValuesToDoubleSequentially() {
814          ConcurrentHashMap<Long, Long> m = longMap();
815 <        double dr = m.reduceValuesToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum);
815 >        double dr = m.reduceValuesToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum);
816          assertEquals(dr, (double)SIZE * (SIZE - 1));
817      }
818  
# Line 821 | Line 821 | public class ConcurrentHashMap8Test exte
821       */
822      public void testReduceKeysToLongInParallel() {
823          ConcurrentHashMap<Long, Long> m = longMap();
824 <        long lr = m.reduceKeysToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum);
824 >        long lr = m.reduceKeysToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum);
825          assertEquals(lr, (long)SIZE * (SIZE - 1) / 2);
826      }
827  
# Line 830 | Line 830 | public class ConcurrentHashMap8Test exte
830       */
831      public void testReduceKeysToIntInParallel() {
832          ConcurrentHashMap<Long, Long> m = longMap();
833 <        int ir = m.reduceKeysToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum);
833 >        int ir = m.reduceKeysToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum);
834          assertEquals(ir, SIZE * (SIZE - 1) / 2);
835      }
836  
# Line 839 | Line 839 | public class ConcurrentHashMap8Test exte
839       */
840      public void testReduceKeysToDoubleInParallel() {
841          ConcurrentHashMap<Long, Long> m = longMap();
842 <        double dr = m.reduceKeysToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum);
842 >        double dr = m.reduceKeysToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum);
843          assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
844      }
845  
# Line 848 | Line 848 | public class ConcurrentHashMap8Test exte
848       */
849      public void testReduceValuesToLongInParallel() {
850          ConcurrentHashMap<Long, Long> m = longMap();
851 <        long lr = m.reduceValuesToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum);
851 >        long lr = m.reduceValuesToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum);
852          assertEquals(lr, (long)SIZE * (SIZE - 1));
853      }
854  
# Line 857 | Line 857 | public class ConcurrentHashMap8Test exte
857       */
858      public void testReduceValuesToIntInParallel() {
859          ConcurrentHashMap<Long, Long> m = longMap();
860 <        int ir = m.reduceValuesToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum);
860 >        int ir = m.reduceValuesToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum);
861          assertEquals(ir, SIZE * (SIZE - 1));
862      }
863  
# Line 866 | Line 866 | public class ConcurrentHashMap8Test exte
866       */
867      public void testReduceValuesToDoubleInParallel() {
868          ConcurrentHashMap<Long, Long> m = longMap();
869 <        double dr = m.reduceValuesToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum);
869 >        double dr = m.reduceValuesToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum);
870          assertEquals(dr, (double)SIZE * (SIZE - 1));
871      }
872  
# Line 877 | Line 877 | public class ConcurrentHashMap8Test exte
877      public void testSearchKeysSequentially() {
878          ConcurrentHashMap<Long, Long> m = longMap();
879          Long r;
880 <        r = m.searchKeysSequentially((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
880 >        r = m.searchKeys(Long.MAX_VALUE, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
881          assertEquals((long)r, (long)(SIZE/2));
882 <        r = m.searchKeysSequentially((Long x) -> x.longValue() < 0L ? x : null);
882 >        r = m.searchKeys(Long.MAX_VALUE, (Long x) -> x.longValue() < 0L ? x : null);
883          assertNull(r);
884      }
885  
# Line 890 | Line 890 | public class ConcurrentHashMap8Test exte
890      public void testSearchValuesSequentially() {
891          ConcurrentHashMap<Long, Long> m = longMap();
892          Long r;
893 <        r = m.searchValuesSequentially((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
893 >        r = m.searchValues(Long.MAX_VALUE, (Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
894          assertEquals((long)r, (long)(SIZE/2));
895 <        r = m.searchValuesSequentially((Long x) -> x.longValue() < 0L ? x : null);
895 >        r = m.searchValues(Long.MAX_VALUE, (Long x) -> x.longValue() < 0L ? x : null);
896          assertNull(r);
897      }
898  
# Line 903 | Line 903 | public class ConcurrentHashMap8Test exte
903      public void testSearchSequentially() {
904          ConcurrentHashMap<Long, Long> m = longMap();
905          Long r;
906 <        r = m.searchSequentially((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
906 >        r = m.search(Long.MAX_VALUE, (Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
907          assertEquals((long)r, (long)(SIZE/2));
908 <        r = m.searchSequentially((Long x, Long y) -> x.longValue() < 0L ? x : null);
908 >        r = m.search(Long.MAX_VALUE, (Long x, Long y) -> x.longValue() < 0L ? x : null);
909          assertNull(r);
910      }
911  
# Line 916 | Line 916 | public class ConcurrentHashMap8Test exte
916      public void testSearchEntriesSequentially() {
917          ConcurrentHashMap<Long, Long> m = longMap();
918          Long r;
919 <        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
919 >        r = m.searchEntries(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
920          assertEquals((long)r, (long)(SIZE/2));
921 <        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
921 >        r = m.searchEntries(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
922          assertNull(r);
923      }
924  
# Line 929 | Line 929 | public class ConcurrentHashMap8Test exte
929      public void testSearchKeysInParallel() {
930          ConcurrentHashMap<Long, Long> m = longMap();
931          Long r;
932 <        r = m.searchKeysInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
932 >        r = m.searchKeys(1L, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
933          assertEquals((long)r, (long)(SIZE/2));
934 <        r = m.searchKeysInParallel((Long x) -> x.longValue() < 0L ? x : null);
934 >        r = m.searchKeys(1L, (Long x) -> x.longValue() < 0L ? x : null);
935          assertNull(r);
936      }
937  
# Line 942 | Line 942 | public class ConcurrentHashMap8Test exte
942      public void testSearchValuesInParallel() {
943          ConcurrentHashMap<Long, Long> m = longMap();
944          Long r;
945 <        r = m.searchValuesInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
945 >        r = m.searchValues(1L, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
946          assertEquals((long)r, (long)(SIZE/2));
947 <        r = m.searchValuesInParallel((Long x) -> x.longValue() < 0L ? x : null);
947 >        r = m.searchValues(1L, (Long x) -> x.longValue() < 0L ? x : null);
948          assertNull(r);
949      }
950  
# Line 955 | Line 955 | public class ConcurrentHashMap8Test exte
955      public void testSearchInParallel() {
956          ConcurrentHashMap<Long, Long> m = longMap();
957          Long r;
958 <        r = m.searchInParallel((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
958 >        r = m.search(1L, (Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
959          assertEquals((long)r, (long)(SIZE/2));
960 <        r = m.searchInParallel((Long x, Long y) -> x.longValue() < 0L ? x : null);
960 >        r = m.search(1L, (Long x, Long y) -> x.longValue() < 0L ? x : null);
961          assertNull(r);
962      }
963  
# Line 968 | Line 968 | public class ConcurrentHashMap8Test exte
968      public void testSearchEntriesInParallel() {
969          ConcurrentHashMap<Long, Long> m = longMap();
970          Long r;
971 <        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
971 >        r = m.searchEntries(1L, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
972          assertEquals((long)r, (long)(SIZE/2));
973 <        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
973 >        r = m.searchEntries(1L, (Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
974          assertNull(r);
975      }
976  
977    /**
978     * Invoking task versions of bulk methods has same effect as
979     * parallel methods
980     */
981    public void testForkJoinTasks() {
982        LongAdder adder = new LongAdder();
983        ConcurrentHashMap<Long, Long> m = longMap();
984        ConcurrentHashMap.ForkJoinTasks.forEachKey
985            (m, (Long x) -> adder.add(x.longValue())).invoke();
986        assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
987        adder.reset();
988        ConcurrentHashMap.ForkJoinTasks.forEachValue
989            (m, (Long x) -> adder.add(x.longValue())).invoke();
990        assertEquals(adder.sum(), SIZE * (SIZE - 1));
991        adder.reset();
992        ConcurrentHashMap.ForkJoinTasks.forEach
993            (m, (Long x, Long y) -> adder.add(x.longValue() + y.longValue())).invoke();
994        assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
995        adder.reset();
996        ConcurrentHashMap.ForkJoinTasks.forEachEntry
997            (m,
998             (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())).invoke();
999        assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
1000        adder.reset();
1001        ConcurrentHashMap.ForkJoinTasks.forEachKey
1002            (m, (Long x) -> Long.valueOf(4 * x.longValue()),
1003             (Long x) -> adder.add(x.longValue())).invoke();
1004        assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
1005        adder.reset();
1006        ConcurrentHashMap.ForkJoinTasks.forEachValue
1007            (m, (Long x) -> Long.valueOf(4 * x.longValue()),
1008             (Long x) -> adder.add(x.longValue())).invoke();
1009        assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
1010        adder.reset();
1011        ConcurrentHashMap.ForkJoinTasks.forEach
1012            (m, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
1013             (Long x) -> adder.add(x.longValue())).invoke();
1014        assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
1015        adder.reset();
1016        ConcurrentHashMap.ForkJoinTasks.forEachEntry
1017            (m, (Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
1018             (Long x) -> adder.add(x.longValue())).invoke();
1019        assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
1020        adder.reset();
1021
1022        Long r; long lr; int ir; double dr;
1023        r = ConcurrentHashMap.ForkJoinTasks.reduceKeys
1024            (m, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())).invoke();
1025        assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
1026        r = ConcurrentHashMap.ForkJoinTasks.reduceValues
1027            (m, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())).invoke();
1028        assertEquals((long)r, (long)SIZE * (SIZE - 1));
1029        r = ConcurrentHashMap.ForkJoinTasks.reduce
1030            (m, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
1031             (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())).invoke();
1032        assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
1033        r = ConcurrentHashMap.ForkJoinTasks.reduceEntries
1034            (m, (Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()),
1035             (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())).invoke();
1036        assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
1037        r = ConcurrentHashMap.ForkJoinTasks.reduceKeys
1038            (m, (Long x) -> Long.valueOf(4 * x.longValue()),
1039             (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())).invoke();
1040        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2);
1041        lr = ConcurrentHashMap.ForkJoinTasks.reduceKeysToLong
1042            (m, (Long x) -> x.longValue(), 0L, Long::sum).invoke();
1043        assertEquals(lr, (long)SIZE * (SIZE - 1) / 2);
1044        ir = ConcurrentHashMap.ForkJoinTasks.reduceKeysToInt
1045            (m, (Long x) -> x.intValue(), 0, Integer::sum).invoke();
1046        assertEquals(ir, SIZE * (SIZE - 1) / 2);
1047        dr = ConcurrentHashMap.ForkJoinTasks.reduceKeysToDouble
1048            (m, (Long x) -> x.doubleValue(), 0.0, Double::sum).invoke();
1049        assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
1050        r = ConcurrentHashMap.ForkJoinTasks.reduceValues
1051            (m, (Long x) -> Long.valueOf(4 * x.longValue()),
1052             (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())).invoke();
1053        assertEquals((long)r, (long)4 * SIZE * (SIZE - 1));
1054        lr = ConcurrentHashMap.ForkJoinTasks.reduceValuesToLong
1055            (m, (Long x) -> x.longValue(), 0L, Long::sum).invoke();
1056        assertEquals(lr, (long)SIZE * (SIZE - 1));
1057        ir = ConcurrentHashMap.ForkJoinTasks.reduceValuesToInt
1058            (m, (Long x) -> x.intValue(), 0, Integer::sum).invoke();
1059        assertEquals(ir, SIZE * (SIZE - 1));
1060        dr = ConcurrentHashMap.ForkJoinTasks.reduceValuesToDouble
1061            (m, (Long x) -> x.doubleValue(), 0.0, Double::sum).invoke();
1062        assertEquals(dr, (double)SIZE * (SIZE - 1));
1063        r = ConcurrentHashMap.ForkJoinTasks.searchKeys
1064            (m, (Long x) -> x.longValue() == (long)(SIZE/2)? x : null).invoke();
1065        assertEquals((long)r, (long)(SIZE/2));
1066        r = ConcurrentHashMap.ForkJoinTasks.searchValues
1067            (m, (Long x) -> x.longValue() == (long)(SIZE/2)? x : null).invoke();
1068        assertEquals((long)r, (long)(SIZE/2));
1069        r = ConcurrentHashMap.ForkJoinTasks.search
1070            (m, (Long x, Long y) -> x.longValue() == (long)(SIZE/2)? x : null).invoke();
1071        assertEquals((long)r, (long)(SIZE/2));
1072        r = ConcurrentHashMap.ForkJoinTasks.searchEntries
1073            (m, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null).invoke();
1074        assertEquals((long)r, (long)(SIZE/2));
1075    }
977   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines