4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
< |
import junit.framework.*; |
8 |
< |
import java.util.*; |
9 |
< |
import java.util.function.*; |
10 |
< |
import java.util.concurrent.atomic.LongAdder; |
7 |
> |
import static java.util.Spliterator.CONCURRENT; |
8 |
> |
import static java.util.Spliterator.DISTINCT; |
9 |
> |
import static java.util.Spliterator.NONNULL; |
10 |
> |
|
11 |
> |
import java.util.AbstractMap; |
12 |
> |
import java.util.Arrays; |
13 |
> |
import java.util.Collection; |
14 |
> |
import java.util.Collections; |
15 |
> |
import java.util.Iterator; |
16 |
> |
import java.util.Map; |
17 |
> |
import java.util.NoSuchElementException; |
18 |
> |
import java.util.Set; |
19 |
> |
import java.util.Spliterator; |
20 |
> |
import java.util.Vector; |
21 |
|
import java.util.concurrent.ConcurrentHashMap; |
22 |
+ |
import java.util.concurrent.atomic.LongAdder; |
23 |
+ |
import java.util.function.BiFunction; |
24 |
+ |
|
25 |
+ |
import junit.framework.Test; |
26 |
+ |
import junit.framework.TestSuite; |
27 |
|
|
28 |
|
public class ConcurrentHashMap8Test extends JSR166TestCase { |
29 |
|
public static void main(String[] args) { |
68 |
|
} |
69 |
|
|
70 |
|
/** |
71 |
< |
* computeIfAbsent does not replace if the key is already present |
71 |
> |
* computeIfAbsent does not replace if the key is already present |
72 |
|
*/ |
73 |
|
public void testComputeIfAbsent2() { |
74 |
|
ConcurrentHashMap map = map5(); |
85 |
|
} |
86 |
|
|
87 |
|
/** |
88 |
< |
* computeIfPresent does not replace if the key is already present |
88 |
> |
* computeIfPresent does not replace if the key is already present |
89 |
|
*/ |
90 |
|
public void testComputeIfPresent() { |
91 |
|
ConcurrentHashMap map = map5(); |
102 |
|
} |
103 |
|
|
104 |
|
/** |
105 |
< |
* compute does not replace if the function returns null |
105 |
> |
* compute does not replace if the function returns null |
106 |
|
*/ |
107 |
|
public void testCompute() { |
108 |
|
ConcurrentHashMap map = map5(); |
181 |
|
} |
182 |
|
|
183 |
|
/** |
184 |
+ |
* replaceAll replaces all matching values. |
185 |
+ |
*/ |
186 |
+ |
public void testReplaceAll() { |
187 |
+ |
ConcurrentHashMap<Integer, String> map = map5(); |
188 |
+ |
map.replaceAll((x, y) -> { return x > 3 ? "Z" : y; }); |
189 |
+ |
assertEquals("A", map.get(one)); |
190 |
+ |
assertEquals("B", map.get(two)); |
191 |
+ |
assertEquals("C", map.get(three)); |
192 |
+ |
assertEquals("Z", map.get(four)); |
193 |
+ |
assertEquals("Z", map.get(five)); |
194 |
+ |
} |
195 |
+ |
|
196 |
+ |
/** |
197 |
|
* Default-constructed set is empty |
198 |
|
*/ |
199 |
|
public void testNewKeySet() { |
202 |
|
} |
203 |
|
|
204 |
|
/** |
205 |
+ |
* keySet.add adds the key with the established value to the map; |
206 |
+ |
* remove removes it. |
207 |
+ |
*/ |
208 |
+ |
public void testKeySetAddRemove() { |
209 |
+ |
ConcurrentHashMap map = map5(); |
210 |
+ |
Set set1 = map.keySet(); |
211 |
+ |
Set set2 = map.keySet(true); |
212 |
+ |
set2.add(six); |
213 |
+ |
assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map); |
214 |
+ |
assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map); |
215 |
+ |
assertEquals(set2.size(), map.size()); |
216 |
+ |
assertEquals(set1.size(), map.size()); |
217 |
+ |
assertTrue((Boolean)map.get(six)); |
218 |
+ |
assertTrue(set1.contains(six)); |
219 |
+ |
assertTrue(set2.contains(six)); |
220 |
+ |
set2.remove(six); |
221 |
+ |
assertNull(map.get(six)); |
222 |
+ |
assertFalse(set1.contains(six)); |
223 |
+ |
assertFalse(set2.contains(six)); |
224 |
+ |
} |
225 |
+ |
|
226 |
+ |
/** |
227 |
|
* keySet.addAll adds each element from the given collection |
228 |
|
*/ |
229 |
|
public void testAddAll() { |
269 |
|
} |
270 |
|
|
271 |
|
/** |
272 |
+ |
* keySet.add throws UnsupportedOperationException if no default |
273 |
+ |
* mapped value |
274 |
+ |
*/ |
275 |
+ |
public void testAdd4() { |
276 |
+ |
Set full = map5().keySet(); |
277 |
+ |
try { |
278 |
+ |
full.add(three); |
279 |
+ |
shouldThrow(); |
280 |
+ |
} catch (UnsupportedOperationException e){} |
281 |
+ |
} |
282 |
+ |
|
283 |
+ |
/** |
284 |
+ |
* keySet.add throws NullPointerException if the specified key is |
285 |
+ |
* null |
286 |
+ |
*/ |
287 |
+ |
public void testAdd5() { |
288 |
+ |
Set full = populatedSet(3); |
289 |
+ |
try { |
290 |
+ |
full.add(null); |
291 |
+ |
shouldThrow(); |
292 |
+ |
} catch (NullPointerException e){} |
293 |
+ |
} |
294 |
+ |
|
295 |
+ |
/** |
296 |
+ |
* KeySetView.getMappedValue returns the map's mapped value |
297 |
+ |
*/ |
298 |
+ |
public void testGetMappedValue() { |
299 |
+ |
ConcurrentHashMap map = map5(); |
300 |
+ |
assertNull(map.keySet().getMappedValue()); |
301 |
+ |
try { |
302 |
+ |
map.keySet(null); |
303 |
+ |
shouldThrow(); |
304 |
+ |
} catch (NullPointerException e) {} |
305 |
+ |
ConcurrentHashMap.KeySetView set = map.keySet(one); |
306 |
+ |
set.add(one); |
307 |
+ |
set.add(six); |
308 |
+ |
set.add(seven); |
309 |
+ |
assertTrue(set.getMappedValue() == one); |
310 |
+ |
assertTrue(map.get(one) != one); |
311 |
+ |
assertTrue(map.get(six) == one); |
312 |
+ |
assertTrue(map.get(seven) == one); |
313 |
+ |
} |
314 |
+ |
|
315 |
+ |
void checkSpliteratorCharacteristics(Spliterator<?> sp, |
316 |
+ |
int requiredCharacteristics) { |
317 |
+ |
assertEquals(requiredCharacteristics, |
318 |
+ |
requiredCharacteristics & sp.characteristics()); |
319 |
+ |
} |
320 |
+ |
|
321 |
+ |
/** |
322 |
+ |
* KeySetView.spliterator returns spliterator over the elements in this set |
323 |
+ |
*/ |
324 |
+ |
public void testKeySetSpliterator() { |
325 |
+ |
LongAdder adder = new LongAdder(); |
326 |
+ |
ConcurrentHashMap map = map5(); |
327 |
+ |
Set set = map.keySet(); |
328 |
+ |
Spliterator<Integer> sp = set.spliterator(); |
329 |
+ |
checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL); |
330 |
+ |
assertEquals(sp.estimateSize(), map.size()); |
331 |
+ |
Spliterator<Integer> sp2 = sp.trySplit(); |
332 |
+ |
sp.forEachRemaining((Integer x) -> adder.add(x.longValue())); |
333 |
+ |
long v = adder.sumThenReset(); |
334 |
+ |
sp2.forEachRemaining((Integer x) -> adder.add(x.longValue())); |
335 |
+ |
long v2 = adder.sum(); |
336 |
+ |
assertEquals(v + v2, 15); |
337 |
+ |
} |
338 |
+ |
|
339 |
+ |
/** |
340 |
|
* keyset.clear removes all elements from the set |
341 |
|
*/ |
342 |
|
public void testClear() { |
419 |
|
assertTrue(it.hasNext()); |
420 |
|
it.next(); |
421 |
|
} |
422 |
< |
assertFalse(it.hasNext()); |
423 |
< |
try { |
424 |
< |
it.next(); |
425 |
< |
shouldThrow(); |
426 |
< |
} catch (NoSuchElementException success) {} |
422 |
> |
assertIteratorExhausted(it); |
423 |
> |
} |
424 |
> |
|
425 |
> |
/** |
426 |
> |
* iterator of empty collections has no elements |
427 |
> |
*/ |
428 |
> |
public void testEmptyIterator() { |
429 |
> |
assertIteratorExhausted(ConcurrentHashMap.newKeySet().iterator()); |
430 |
> |
assertIteratorExhausted(new ConcurrentHashMap().entrySet().iterator()); |
431 |
> |
assertIteratorExhausted(new ConcurrentHashMap().values().iterator()); |
432 |
> |
assertIteratorExhausted(new ConcurrentHashMap().keySet().iterator()); |
433 |
|
} |
434 |
|
|
435 |
|
/** |
555 |
|
Set x = populatedSet(size); |
556 |
|
Set y = serialClone(x); |
557 |
|
|
558 |
< |
assertTrue(x != y); |
558 |
> |
assertNotSame(x, y); |
559 |
|
assertEquals(x.size(), y.size()); |
436 |
– |
assertEquals(x.toString(), y.toString()); |
437 |
– |
assertTrue(Arrays.equals(x.toArray(), y.toArray())); |
560 |
|
assertEquals(x, y); |
561 |
|
assertEquals(y, x); |
562 |
|
} |
563 |
|
|
442 |
– |
|
564 |
|
static final int SIZE = 10000; |
565 |
|
static ConcurrentHashMap<Long, Long> longMap; |
566 |
|
|
588 |
|
public void testForEachKeySequentially() { |
589 |
|
LongAdder adder = new LongAdder(); |
590 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
591 |
< |
m.forEachKeySequentially((Long x) -> adder.add(x.longValue())); |
591 |
> |
m.forEachKey(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue())); |
592 |
|
assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2); |
593 |
|
} |
594 |
|
|
598 |
|
public void testForEachValueSequentially() { |
599 |
|
LongAdder adder = new LongAdder(); |
600 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
601 |
< |
m.forEachValueSequentially((Long x) -> adder.add(x.longValue())); |
601 |
> |
m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue())); |
602 |
|
assertEquals(adder.sum(), SIZE * (SIZE - 1)); |
603 |
|
} |
604 |
|
|
608 |
|
public void testForEachSequentially() { |
609 |
|
LongAdder adder = new LongAdder(); |
610 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
611 |
< |
m.forEachSequentially((Long x, Long y) -> adder.add(x.longValue() + y.longValue())); |
611 |
> |
m.forEach(Long.MAX_VALUE, (Long x, Long y) -> adder.add(x.longValue() + y.longValue())); |
612 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
613 |
|
} |
614 |
|
|
618 |
|
public void testForEachEntrySequentially() { |
619 |
|
LongAdder adder = new LongAdder(); |
620 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
621 |
< |
m.forEachEntrySequentially((Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())); |
621 |
> |
m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())); |
622 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
623 |
|
} |
624 |
|
|
628 |
|
public void testForEachKeyInParallel() { |
629 |
|
LongAdder adder = new LongAdder(); |
630 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
631 |
< |
m.forEachKeyInParallel((Long x) -> adder.add(x.longValue())); |
631 |
> |
m.forEachKey(1L, (Long x) -> adder.add(x.longValue())); |
632 |
|
assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2); |
633 |
|
} |
634 |
|
|
638 |
|
public void testForEachValueInParallel() { |
639 |
|
LongAdder adder = new LongAdder(); |
640 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
641 |
< |
m.forEachValueInParallel((Long x) -> adder.add(x.longValue())); |
641 |
> |
m.forEachValue(1L, (Long x) -> adder.add(x.longValue())); |
642 |
|
assertEquals(adder.sum(), SIZE * (SIZE - 1)); |
643 |
|
} |
644 |
|
|
648 |
|
public void testForEachInParallel() { |
649 |
|
LongAdder adder = new LongAdder(); |
650 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
651 |
< |
m.forEachInParallel((Long x, Long y) -> adder.add(x.longValue() + y.longValue())); |
651 |
> |
m.forEach(1L, (Long x, Long y) -> adder.add(x.longValue() + y.longValue())); |
652 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
653 |
|
} |
654 |
|
|
658 |
|
public void testForEachEntryInParallel() { |
659 |
|
LongAdder adder = new LongAdder(); |
660 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
661 |
< |
m.forEachEntryInParallel((Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())); |
661 |
> |
m.forEachEntry(1L, (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())); |
662 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
663 |
|
} |
664 |
|
|
669 |
|
public void testMappedForEachKeySequentially() { |
670 |
|
LongAdder adder = new LongAdder(); |
671 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
672 |
< |
m.forEachKeySequentially((Long x) -> Long.valueOf(4 * x.longValue()), |
672 |
> |
m.forEachKey(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), |
673 |
|
(Long x) -> adder.add(x.longValue())); |
674 |
|
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2); |
675 |
|
} |
681 |
|
public void testMappedForEachValueSequentially() { |
682 |
|
LongAdder adder = new LongAdder(); |
683 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
684 |
< |
m.forEachValueSequentially((Long x) -> Long.valueOf(4 * x.longValue()), |
684 |
> |
m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), |
685 |
|
(Long x) -> adder.add(x.longValue())); |
686 |
|
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1)); |
687 |
|
} |
693 |
|
public void testMappedForEachSequentially() { |
694 |
|
LongAdder adder = new LongAdder(); |
695 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
696 |
< |
m.forEachSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
696 |
> |
m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
697 |
|
(Long x) -> adder.add(x.longValue())); |
698 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
699 |
|
} |
705 |
|
public void testMappedForEachEntrySequentially() { |
706 |
|
LongAdder adder = new LongAdder(); |
707 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
708 |
< |
m.forEachEntrySequentially((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), |
708 |
> |
m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), |
709 |
|
(Long x) -> adder.add(x.longValue())); |
710 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
711 |
|
} |
717 |
|
public void testMappedForEachKeyInParallel() { |
718 |
|
LongAdder adder = new LongAdder(); |
719 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
720 |
< |
m.forEachKeyInParallel((Long x) -> Long.valueOf(4 * x.longValue()), |
720 |
> |
m.forEachKey(1L, (Long x) -> Long.valueOf(4 * x.longValue()), |
721 |
|
(Long x) -> adder.add(x.longValue())); |
722 |
|
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2); |
723 |
|
} |
729 |
|
public void testMappedForEachValueInParallel() { |
730 |
|
LongAdder adder = new LongAdder(); |
731 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
732 |
< |
m.forEachValueInParallel((Long x) -> Long.valueOf(4 * x.longValue()), |
732 |
> |
m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()), |
733 |
|
(Long x) -> adder.add(x.longValue())); |
734 |
|
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1)); |
735 |
|
} |
741 |
|
public void testMappedForEachInParallel() { |
742 |
|
LongAdder adder = new LongAdder(); |
743 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
744 |
< |
m.forEachInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
744 |
> |
m.forEach(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
745 |
|
(Long x) -> adder.add(x.longValue())); |
746 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
747 |
|
} |
753 |
|
public void testMappedForEachEntryInParallel() { |
754 |
|
LongAdder adder = new LongAdder(); |
755 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
756 |
< |
m.forEachEntryInParallel((Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), |
756 |
> |
m.forEachEntry(1L, (Map.Entry<Long,Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), |
757 |
|
(Long x) -> adder.add(x.longValue())); |
758 |
|
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2); |
759 |
|
} |
760 |
|
|
640 |
– |
|
761 |
|
/** |
762 |
|
* reduceKeysSequentially accumulates across all keys, |
763 |
|
*/ |
764 |
|
public void testReduceKeysSequentially() { |
765 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
766 |
|
Long r; |
767 |
< |
r = m.reduceKeysSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
767 |
> |
r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
768 |
|
assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); |
769 |
|
} |
770 |
|
|
774 |
|
public void testReduceValuesSequentially() { |
775 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
776 |
|
Long r; |
777 |
< |
r = m.reduceKeysSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
777 |
> |
r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
778 |
|
assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); |
779 |
|
} |
780 |
|
|
661 |
– |
|
781 |
|
/** |
782 |
|
* reduceEntriesSequentially accumulates across all entries |
783 |
|
*/ |
784 |
|
public void testReduceEntriesSequentially() { |
785 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
786 |
|
Map.Entry<Long,Long> r; |
787 |
< |
r = m.reduceEntriesSequentially(new AddKeys()); |
787 |
> |
r = m.reduceEntries(Long.MAX_VALUE, new AddKeys()); |
788 |
|
assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2); |
789 |
|
} |
790 |
|
|
794 |
|
public void testReduceKeysInParallel() { |
795 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
796 |
|
Long r; |
797 |
< |
r = m.reduceKeysInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
797 |
> |
r = m.reduceKeys(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
798 |
|
assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); |
799 |
|
} |
800 |
|
|
804 |
|
public void testReduceValuesInParallel() { |
805 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
806 |
|
Long r; |
807 |
< |
r = m.reduceValuesInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
807 |
> |
r = m.reduceValues(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
808 |
|
assertEquals((long)r, (long)SIZE * (SIZE - 1)); |
809 |
|
} |
810 |
|
|
814 |
|
public void testReduceEntriesInParallel() { |
815 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
816 |
|
Map.Entry<Long,Long> r; |
817 |
< |
r = m.reduceEntriesInParallel(new AddKeys()); |
817 |
> |
r = m.reduceEntries(1L, new AddKeys()); |
818 |
|
assertEquals(r.getKey().longValue(), (long)SIZE * (SIZE - 1) / 2); |
819 |
|
} |
820 |
|
|
823 |
|
*/ |
824 |
|
public void testMapReduceKeysSequentially() { |
825 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
826 |
< |
Long r = m.reduceKeysSequentially((Long x) -> Long.valueOf(4 * x.longValue()), |
826 |
> |
Long r = m.reduceKeys(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), |
827 |
|
(Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
828 |
|
assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2); |
829 |
|
} |
833 |
|
*/ |
834 |
|
public void testMapReduceValuesSequentially() { |
835 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
836 |
< |
Long r = m.reduceValuesSequentially((Long x) -> Long.valueOf(4 * x.longValue()), |
836 |
> |
Long r = m.reduceValues(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), |
837 |
|
(Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
838 |
|
assertEquals((long)r, (long)4 * SIZE * (SIZE - 1)); |
839 |
|
} |
843 |
|
*/ |
844 |
|
public void testMappedReduceSequentially() { |
845 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
846 |
< |
Long r = m.reduceSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
846 |
> |
Long r = m.reduce(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
847 |
|
(Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
848 |
|
|
849 |
|
assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2); |
854 |
|
*/ |
855 |
|
public void testMapReduceKeysInParallel() { |
856 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
857 |
< |
Long r = m.reduceKeysInParallel((Long x) -> Long.valueOf(4 * x.longValue()), |
857 |
> |
Long r = m.reduceKeys(1L, (Long x) -> Long.valueOf(4 * x.longValue()), |
858 |
|
(Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
859 |
|
assertEquals((long)r, (long)4 * SIZE * (SIZE - 1) / 2); |
860 |
|
} |
864 |
|
*/ |
865 |
|
public void testMapReduceValuesInParallel() { |
866 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
867 |
< |
Long r = m.reduceValuesInParallel((Long x) -> Long.valueOf(4 * x.longValue()), |
867 |
> |
Long r = m.reduceValues(1L, (Long x) -> Long.valueOf(4 * x.longValue()), |
868 |
|
(Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
869 |
|
assertEquals((long)r, (long)4 * SIZE * (SIZE - 1)); |
870 |
|
} |
875 |
|
public void testMappedReduceInParallel() { |
876 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
877 |
|
Long r; |
878 |
< |
r = m.reduceInParallel((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
878 |
> |
r = m.reduce(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), |
879 |
|
(Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); |
880 |
|
assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2); |
881 |
|
} |
882 |
|
|
764 |
– |
|
883 |
|
/** |
884 |
|
* reduceKeysToLongSequentially accumulates mapped keys |
885 |
|
*/ |
886 |
|
public void testReduceKeysToLongSequentially() { |
887 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
888 |
< |
long lr = m.reduceKeysToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum); |
888 |
> |
long lr = m.reduceKeysToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum); |
889 |
|
assertEquals(lr, (long)SIZE * (SIZE - 1) / 2); |
890 |
|
} |
891 |
|
|
894 |
|
*/ |
895 |
|
public void testReduceKeysToIntSequentially() { |
896 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
897 |
< |
int ir = m.reduceKeysToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum); |
897 |
> |
int ir = m.reduceKeysToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum); |
898 |
|
assertEquals(ir, SIZE * (SIZE - 1) / 2); |
899 |
|
} |
900 |
|
|
903 |
|
*/ |
904 |
|
public void testReduceKeysToDoubleSequentially() { |
905 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
906 |
< |
double dr = m.reduceKeysToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum); |
906 |
> |
double dr = m.reduceKeysToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum); |
907 |
|
assertEquals(dr, (double)SIZE * (SIZE - 1) / 2); |
908 |
|
} |
909 |
|
|
912 |
|
*/ |
913 |
|
public void testReduceValuesToLongSequentially() { |
914 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
915 |
< |
long lr = m.reduceValuesToLongSequentially((Long x) -> x.longValue(), 0L, Long::sum); |
915 |
> |
long lr = m.reduceValuesToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum); |
916 |
|
assertEquals(lr, (long)SIZE * (SIZE - 1)); |
917 |
|
} |
918 |
|
|
921 |
|
*/ |
922 |
|
public void testReduceValuesToIntSequentially() { |
923 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
924 |
< |
int ir = m.reduceValuesToIntSequentially((Long x) -> x.intValue(), 0, Integer::sum); |
924 |
> |
int ir = m.reduceValuesToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum); |
925 |
|
assertEquals(ir, SIZE * (SIZE - 1)); |
926 |
|
} |
927 |
|
|
930 |
|
*/ |
931 |
|
public void testReduceValuesToDoubleSequentially() { |
932 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
933 |
< |
double dr = m.reduceValuesToDoubleSequentially((Long x) -> x.doubleValue(), 0.0, Double::sum); |
933 |
> |
double dr = m.reduceValuesToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum); |
934 |
|
assertEquals(dr, (double)SIZE * (SIZE - 1)); |
935 |
|
} |
936 |
|
|
939 |
|
*/ |
940 |
|
public void testReduceKeysToLongInParallel() { |
941 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
942 |
< |
long lr = m.reduceKeysToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum); |
942 |
> |
long lr = m.reduceKeysToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum); |
943 |
|
assertEquals(lr, (long)SIZE * (SIZE - 1) / 2); |
944 |
|
} |
945 |
|
|
948 |
|
*/ |
949 |
|
public void testReduceKeysToIntInParallel() { |
950 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
951 |
< |
int ir = m.reduceKeysToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum); |
951 |
> |
int ir = m.reduceKeysToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum); |
952 |
|
assertEquals(ir, SIZE * (SIZE - 1) / 2); |
953 |
|
} |
954 |
|
|
957 |
|
*/ |
958 |
|
public void testReduceKeysToDoubleInParallel() { |
959 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
960 |
< |
double dr = m.reduceKeysToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum); |
960 |
> |
double dr = m.reduceKeysToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum); |
961 |
|
assertEquals(dr, (double)SIZE * (SIZE - 1) / 2); |
962 |
|
} |
963 |
|
|
966 |
|
*/ |
967 |
|
public void testReduceValuesToLongInParallel() { |
968 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
969 |
< |
long lr = m.reduceValuesToLongInParallel((Long x) -> x.longValue(), 0L, Long::sum); |
969 |
> |
long lr = m.reduceValuesToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum); |
970 |
|
assertEquals(lr, (long)SIZE * (SIZE - 1)); |
971 |
|
} |
972 |
|
|
975 |
|
*/ |
976 |
|
public void testReduceValuesToIntInParallel() { |
977 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
978 |
< |
int ir = m.reduceValuesToIntInParallel((Long x) -> x.intValue(), 0, Integer::sum); |
978 |
> |
int ir = m.reduceValuesToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum); |
979 |
|
assertEquals(ir, SIZE * (SIZE - 1)); |
980 |
|
} |
981 |
|
|
984 |
|
*/ |
985 |
|
public void testReduceValuesToDoubleInParallel() { |
986 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
987 |
< |
double dr = m.reduceValuesToDoubleInParallel((Long x) -> x.doubleValue(), 0.0, Double::sum); |
987 |
> |
double dr = m.reduceValuesToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum); |
988 |
|
assertEquals(dr, (double)SIZE * (SIZE - 1)); |
989 |
|
} |
990 |
|
|
995 |
|
public void testSearchKeysSequentially() { |
996 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
997 |
|
Long r; |
998 |
< |
r = m.searchKeysSequentially((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); |
998 |
> |
r = m.searchKeys(Long.MAX_VALUE, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); |
999 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1000 |
< |
r = m.searchKeysSequentially((Long x) -> x.longValue() < 0L ? x : null); |
1000 |
> |
r = m.searchKeys(Long.MAX_VALUE, (Long x) -> x.longValue() < 0L ? x : null); |
1001 |
|
assertNull(r); |
1002 |
|
} |
1003 |
|
|
1008 |
|
public void testSearchValuesSequentially() { |
1009 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1010 |
|
Long r; |
1011 |
< |
r = m.searchValuesSequentially((Long x) -> x.longValue() == (long)(SIZE/2)? x : null); |
1011 |
> |
r = m.searchValues(Long.MAX_VALUE, |
1012 |
> |
(Long x) -> (x.longValue() == (long)(SIZE/2)) ? x : null); |
1013 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1014 |
< |
r = m.searchValuesSequentially((Long x) -> x.longValue() < 0L ? x : null); |
1014 |
> |
r = m.searchValues(Long.MAX_VALUE, |
1015 |
> |
(Long x) -> (x.longValue() < 0L) ? x : null); |
1016 |
|
assertNull(r); |
1017 |
|
} |
1018 |
|
|
1023 |
|
public void testSearchSequentially() { |
1024 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1025 |
|
Long r; |
1026 |
< |
r = m.searchSequentially((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1026 |
> |
r = m.search(Long.MAX_VALUE, (Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1027 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1028 |
< |
r = m.searchSequentially((Long x, Long y) -> x.longValue() < 0L ? x : null); |
1028 |
> |
r = m.search(Long.MAX_VALUE, (Long x, Long y) -> x.longValue() < 0L ? x : null); |
1029 |
|
assertNull(r); |
1030 |
|
} |
1031 |
|
|
1036 |
|
public void testSearchEntriesSequentially() { |
1037 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1038 |
|
Long r; |
1039 |
< |
r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null); |
1039 |
> |
r = m.searchEntries(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null); |
1040 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1041 |
< |
r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null); |
1041 |
> |
r = m.searchEntries(Long.MAX_VALUE, (Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null); |
1042 |
|
assertNull(r); |
1043 |
|
} |
1044 |
|
|
1049 |
|
public void testSearchKeysInParallel() { |
1050 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1051 |
|
Long r; |
1052 |
< |
r = m.searchKeysInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1052 |
> |
r = m.searchKeys(1L, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1053 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1054 |
< |
r = m.searchKeysInParallel((Long x) -> x.longValue() < 0L ? x : null); |
1054 |
> |
r = m.searchKeys(1L, (Long x) -> x.longValue() < 0L ? x : null); |
1055 |
|
assertNull(r); |
1056 |
|
} |
1057 |
|
|
1062 |
|
public void testSearchValuesInParallel() { |
1063 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1064 |
|
Long r; |
1065 |
< |
r = m.searchValuesInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1065 |
> |
r = m.searchValues(1L, (Long x) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1066 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1067 |
< |
r = m.searchValuesInParallel((Long x) -> x.longValue() < 0L ? x : null); |
1067 |
> |
r = m.searchValues(1L, (Long x) -> x.longValue() < 0L ? x : null); |
1068 |
|
assertNull(r); |
1069 |
|
} |
1070 |
|
|
1075 |
|
public void testSearchInParallel() { |
1076 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1077 |
|
Long r; |
1078 |
< |
r = m.searchInParallel((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1078 |
> |
r = m.search(1L, (Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null); |
1079 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1080 |
< |
r = m.searchInParallel((Long x, Long y) -> x.longValue() < 0L ? x : null); |
1080 |
> |
r = m.search(1L, (Long x, Long y) -> x.longValue() < 0L ? x : null); |
1081 |
|
assertNull(r); |
1082 |
|
} |
1083 |
|
|
1088 |
|
public void testSearchEntriesInParallel() { |
1089 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1090 |
|
Long r; |
1091 |
< |
r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null); |
1091 |
> |
r = m.searchEntries(1L, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null); |
1092 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1093 |
< |
r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null); |
1093 |
> |
r = m.searchEntries(1L, (Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null); |
1094 |
|
assertNull(r); |
1095 |
|
} |
1096 |
|
|
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 |
– |
} |
1097 |
|
} |