use of org.eclipse.collections.api.map.primitive.ObjectDoubleMap in project eclipse-collections by eclipse.
the class ParallelIterateTest method sumByDouble.
@Test
public void sumByDouble() {
Interval interval = Interval.oneTo(100000);
ObjectDoubleMap<String> sumByCount = ParallelIterate.sumByDouble(interval, EVEN_OR_ODD, i -> 1.0d);
Assert.assertEquals(50000.0, sumByCount.get("Even"), 0.0);
Assert.assertEquals(50000.0, sumByCount.get("Odd"), 0.0);
ObjectDoubleMap<String> sumByValue = ParallelIterate.sumByDouble(interval, EVEN_OR_ODD, Integer::doubleValue);
Assert.assertEquals(interval.sumByDouble(EVEN_OR_ODD, Integer::doubleValue), sumByValue);
ObjectDoubleMap<Integer> sumByValue2 = ParallelIterate.sumByDouble(interval, i -> i % 1000, Integer::doubleValue);
Assert.assertEquals(interval.sumByDouble(i -> i % 1000, Integer::doubleValue), sumByValue2);
Interval interval2 = Interval.oneTo(UNEVEN_COUNT_FOR_SUMBY);
ObjectDoubleMap<String> sumByValue3 = ParallelIterate.sumByDouble(interval2, EVEN_OR_ODD, Integer::doubleValue);
Assert.assertEquals(interval2.sumByDouble(EVEN_OR_ODD, Integer::doubleValue), sumByValue3);
ObjectDoubleMap<Integer> sumByValue4 = ParallelIterate.sumByDouble(interval2, i -> i % 1000, Integer::doubleValue);
Assert.assertEquals(interval2.sumByDouble(i -> i % 1000, Integer::doubleValue), sumByValue4);
Interval small = Interval.oneTo(11);
ObjectDoubleMap<String> smallSumByCount = ParallelIterate.sumByDouble(small, EVEN_OR_ODD, i -> 1.0d);
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.ObjectDoubleMap in project eclipse-collections by eclipse.
the class ParallelIterateTest method sumByFloat.
@Test
public void sumByFloat() {
Interval interval = Interval.oneTo(100000);
ObjectDoubleMap<String> sumByCount = ParallelIterate.sumByFloat(interval, EVEN_OR_ODD, i -> 1.0f);
Assert.assertEquals(50000.0, sumByCount.get("Even"), 0.0);
Assert.assertEquals(50000.0, sumByCount.get("Odd"), 0.0);
ObjectDoubleMap<String> sumByValue = ParallelIterate.sumByFloat(interval, EVEN_OR_ODD, Integer::floatValue);
Assert.assertEquals(interval.sumByFloat(EVEN_OR_ODD, Integer::floatValue), sumByValue);
ObjectDoubleMap<Integer> sumByValue2 = ParallelIterate.sumByFloat(interval, i -> i % 1000, Integer::floatValue);
Assert.assertEquals(interval.sumByDouble(i -> i % 1000, Integer::doubleValue), sumByValue2);
Interval interval2 = Interval.oneTo(UNEVEN_COUNT_FOR_SUMBY);
ObjectDoubleMap<String> sumByValue3 = ParallelIterate.sumByFloat(interval2, EVEN_OR_ODD, Integer::floatValue);
Assert.assertEquals(interval2.sumByFloat(EVEN_OR_ODD, Integer::floatValue), sumByValue3);
ObjectDoubleMap<Integer> sumByValue4 = ParallelIterate.sumByFloat(interval2, i -> i % 1000, Integer::floatValue);
Assert.assertEquals(interval2.sumByFloat(i -> i % 1000, Integer::floatValue), sumByValue4);
Interval small = Interval.oneTo(11);
ObjectDoubleMap<String> smallSumByCount = ParallelIterate.sumByFloat(small, EVEN_OR_ODD, i -> 1.0f);
Assert.assertEquals(5.0, smallSumByCount.get("Even"), 0.0);
Assert.assertEquals(6.0, smallSumByCount.get("Odd"), 0.0);
}
Aggregations