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

The following are Jave code examples for showing how to use reduceKeys() 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.
+ Save this method
Example 1
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   View Source Code Vote up 5 votes
/**
 * reduceKeysSequentially accumulates across all keys,
 */
public void testReduceKeysSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    Long r;
    r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
    assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
}
 
Example 2
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   View Source Code Vote up 5 votes
/**
 * reduceValuesSequentially accumulates across all values
 */
public void testReduceValuesSequentially() {
    ConcurrentHashMap<Long, Long> m = longMap();
    Long r;
    r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
    assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
}
 
Example 3
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   View Source Code Vote up 5 votes
/**
 * reduceKeysInParallel accumulates across all keys
 */
public void testReduceKeysInParallel() {
    ConcurrentHashMap<Long, Long> m = longMap();
    Long r;
    r = m.reduceKeys(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
    assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2);
}