Java Code Examples for java.util.concurrent.ConcurrentHashMap#reduceKeysToInt()

The following examples show how to use java.util.concurrent.ConcurrentHashMap#reduceKeysToInt() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * reduceKeysToIntSequentially accumulates mapped keys
 */
public void testReduceKeysToIntSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    int ir = m.reduceKeysToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum);
    assertEquals(ir, SIZE * (SIZE - 1) / 2);
}
 
Example 2
/**
 * reduceKeysToIntInParallel accumulates mapped keys
 */
public void testReduceKeysToIntInParallel() {
    ConcurrentHashMap<Long, Long> m = longMap();
    int ir = m.reduceKeysToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum);
    assertEquals(ir, SIZE * (SIZE - 1) / 2);
}
 
Example 3
Source Project: j2objc   File: ConcurrentHashMap8Test.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * reduceKeysToIntSequentially accumulates mapped keys
 */
public void testReduceKeysToIntSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    int ir = m.reduceKeysToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum);
    assertEquals(ir, SIZE * (SIZE - 1) / 2);
}
 
Example 4
Source Project: j2objc   File: ConcurrentHashMap8Test.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * reduceKeysToIntInParallel accumulates mapped keys
 */
public void testReduceKeysToIntInParallel() {
    ConcurrentHashMap<Long, Long> m = longMap();
    int ir = m.reduceKeysToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum);
    assertEquals(ir, SIZE * (SIZE - 1) / 2);
}