下面列出了java.util.concurrent.ConcurrentHashMap#reduceValuesToInt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* reduceValuesToIntSequentially accumulates mapped values
*/
public void testReduceValuesToIntSequentially() {
ConcurrentHashMap<Long, Long> m = longMap();
int ir = m.reduceValuesToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum);
assertEquals(ir, SIZE * (SIZE - 1));
}
/**
* reduceValuesToIntInParallel accumulates mapped values
*/
public void testReduceValuesToIntInParallel() {
ConcurrentHashMap<Long, Long> m = longMap();
int ir = m.reduceValuesToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum);
assertEquals(ir, SIZE * (SIZE - 1));
}
/**
* reduceValuesToIntSequentially accumulates mapped values
*/
public void testReduceValuesToIntSequentially() {
ConcurrentHashMap<Long, Long> m = longMap();
int ir = m.reduceValuesToInt(Long.MAX_VALUE, (Long x) -> x.intValue(), 0, Integer::sum);
assertEquals(ir, SIZE * (SIZE - 1));
}
/**
* reduceValuesToIntInParallel accumulates mapped values
*/
public void testReduceValuesToIntInParallel() {
ConcurrentHashMap<Long, Long> m = longMap();
int ir = m.reduceValuesToInt(1L, (Long x) -> x.intValue(), 0, Integer::sum);
assertEquals(ir, SIZE * (SIZE - 1));
}