Java Code Examples for java.util.concurrent.ConcurrentHashMap.reduceValuesToLong()

The following are Jave code examples for showing how to use reduceValuesToLong() of the java.util.concurrent.ConcurrentHashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   Source Code and License Vote up 5 votes
/**
 * reduceValuesToLongSequentially accumulates mapped values
 */
public void testReduceValuesToLongSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    long lr = m.reduceValuesToLong(Long.MAX_VALUE, (Long x) -> x.longValue(), 0L, Long::sum);
    assertEquals(lr, (long)SIZE * (SIZE - 1));
}
 
Example 2
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   Source Code and License Vote up 5 votes
/**
 * reduceValuesToLongInParallel accumulates mapped values
 */
public void testReduceValuesToLongInParallel() {
    ConcurrentHashMap<Long, Long> m = longMap();
    long lr = m.reduceValuesToLong(1L, (Long x) -> x.longValue(), 0L, Long::sum);
    assertEquals(lr, (long)SIZE * (SIZE - 1));
}