use of org.eclipse.collections.api.map.primitive.ObjectLongMap in project eclipse-collections by eclipse.
the class ParallelIterateTest method sumByInt.
@Test
public void sumByInt() {
Interval interval = Interval.oneTo(100000);
ObjectLongMap<String> sumByCount = ParallelIterate.sumByInt(interval, EVEN_OR_ODD, i -> 1);
Assert.assertEquals(50000, sumByCount.get("Even"));
Assert.assertEquals(50000, sumByCount.get("Odd"));
ObjectLongMap<String> sumByValue = ParallelIterate.sumByInt(interval, EVEN_OR_ODD, Integer::intValue);
Assert.assertEquals(interval.sumByInt(EVEN_OR_ODD, Integer::intValue), sumByValue);
ObjectLongMap<Integer> sumByValue2 = ParallelIterate.sumByInt(interval, i -> i % 1000, Integer::intValue);
Assert.assertEquals(interval.sumByInt(i -> i % 1000, Integer::intValue), sumByValue2);
Interval interval2 = Interval.oneTo(UNEVEN_COUNT_FOR_SUMBY);
ObjectLongMap<String> sumByValue3 = ParallelIterate.sumByInt(interval2, EVEN_OR_ODD, Integer::intValue);
Assert.assertEquals(interval2.sumByInt(EVEN_OR_ODD, Integer::intValue), sumByValue3);
ObjectLongMap<Integer> sumByValue4 = ParallelIterate.sumByInt(interval2, i -> i % 1000, Integer::intValue);
Assert.assertEquals(interval2.sumByInt(i -> i % 1000, Integer::intValue), sumByValue4);
Interval small = Interval.oneTo(11);
ObjectLongMap<String> smallSumByCount = ParallelIterate.sumByInt(small, EVEN_OR_ODD, i -> 1);
Assert.assertEquals(5.0, smallSumByCount.get("Even"), 0.0);
Assert.assertEquals(6.0, smallSumByCount.get("Odd"), 0.0);
}
use of org.eclipse.collections.api.map.primitive.ObjectLongMap in project eclipse-collections by eclipse.
the class ParallelIterateTest method sumByLong.
@Test
public void sumByLong() {
Interval interval = Interval.oneTo(100000);
ObjectLongMap<String> sumByCount = ParallelIterate.sumByLong(interval, EVEN_OR_ODD, i -> 1L);
Assert.assertEquals(50000, sumByCount.get("Even"));
Assert.assertEquals(50000, sumByCount.get("Odd"));
ObjectLongMap<String> sumByValue = ParallelIterate.sumByLong(interval, EVEN_OR_ODD, Integer::longValue);
Assert.assertEquals(interval.sumByLong(EVEN_OR_ODD, Integer::longValue), sumByValue);
ObjectLongMap<Integer> sumByValue2 = ParallelIterate.sumByLong(interval, i -> i % 1000, Integer::longValue);
Assert.assertEquals(interval.sumByLong(i -> i % 1000, Integer::longValue), sumByValue2);
Interval interval2 = Interval.oneTo(UNEVEN_COUNT_FOR_SUMBY);
ObjectLongMap<String> sumByValue3 = ParallelIterate.sumByLong(interval2, EVEN_OR_ODD, Integer::longValue);
Assert.assertEquals(interval2.sumByLong(EVEN_OR_ODD, Integer::longValue), sumByValue3);
ObjectLongMap<Integer> sumByValue4 = ParallelIterate.sumByLong(interval2, i -> i % 1000, Integer::longValue);
Assert.assertEquals(interval2.sumByLong(i -> i % 1000, Integer::longValue), sumByValue4);
Interval small = Interval.oneTo(11);
ObjectLongMap<String> smallSumByCount = ParallelIterate.sumByLong(small, EVEN_OR_ODD, i -> 1L);
Assert.assertEquals(5.0, smallSumByCount.get("Even"), 0.0);
Assert.assertEquals(6.0, smallSumByCount.get("Odd"), 0.0);
}
Aggregations