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

The following examples show how to use java.util.concurrent.ConcurrentHashMap#reduceKeysToDouble() .
Example 1
Project: openjdk-jdk9   File: ConcurrentHashMap8Test.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * reduceKeysToDoubleSequentially accumulates mapped keys
 */
public void testReduceKeysToDoubleSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    double dr = m.reduceKeysToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum);
    assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
}
 
Example 2
Project: openjdk-jdk9   File: ConcurrentHashMap8Test.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * reduceKeysToDoubleInParallel accumulates mapped values
 */
public void testReduceKeysToDoubleInParallel() {
    ConcurrentHashMap<Long, Long> m = longMap();
    double dr = m.reduceKeysToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum);
    assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
}
 
Example 3
Project: j2objc   File: ConcurrentHashMap8Test.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * reduceKeysToDoubleSequentially accumulates mapped keys
 */
public void testReduceKeysToDoubleSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    double dr = m.reduceKeysToDouble(Long.MAX_VALUE, (Long x) -> x.doubleValue(), 0.0, Double::sum);
    assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
}
 
Example 4
Project: j2objc   File: ConcurrentHashMap8Test.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * reduceKeysToDoubleInParallel accumulates mapped values
 */
public void testReduceKeysToDoubleInParallel() {
    ConcurrentHashMap<Long, Long> m = longMap();
    double dr = m.reduceKeysToDouble(1L, (Long x) -> x.doubleValue(), 0.0, Double::sum);
    assertEquals(dr, (double)SIZE * (SIZE - 1) / 2);
}