use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testMappedForEachValueInParallel.
/**
* Mapped forEachValueInParallel traverses the given
* transformations of all values
*/
public void testMappedForEachValueInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testMappedForEachEntryInParallel.
/**
* Mapped forEachEntryInParallel traverses the given
* transformations of all entries
*/
public void testMappedForEachEntryInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachValueSequentially.
/**
* forEachValueSequentially traverses all values
*/
public void testForEachValueSequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), SIZE * (SIZE - 1));
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testMappedForEachSequentially.
/**
* Mapped forEachSequentially traverses the given
* transformations of all mappings
*/
public void testMappedForEachSequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testMappedForEachValueSequentially.
/**
* Mapped forEachValueSequentially traverses the given
* transformations of all values
*/
public void testMappedForEachValueSequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}
Aggregations