Search in sources :

Example 1 with DoubleFunction

use of org.eclipse.collections.api.block.function.primitive.DoubleFunction in project eclipse-collections by eclipse.

the class ParallelIterableTestCase method sumOfDoubleConsistentRounding.

@Test
public void sumOfDoubleConsistentRounding() {
    DoubleFunction<Integer> roundingSensitiveElementFunction = i -> (i <= 99995) ? 1.0e-18d : 1.0d;
    MutableList<Integer> list = Interval.oneTo(100_000).toList().shuffleThis();
    double baseline = this.getExpectedWith(list.toArray(new Integer[] {})).sumOfDouble(roundingSensitiveElementFunction);
    for (Integer batchSize : BATCH_SIZES) {
        this.batchSize = batchSize;
        ParallelIterable<Integer> testCollection = this.newWith(list.toArray(new Integer[] {}));
        Assert.assertEquals("Batch size: " + this.batchSize, baseline, testCollection.sumOfDouble(roundingSensitiveElementFunction), 1.0e-15d);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ParallelSortedSetIterable(org.eclipse.collections.api.set.sorted.ParallelSortedSetIterable) NegativeIntervalFunction(org.eclipse.collections.impl.block.function.NegativeIntervalFunction) CharHashBag(org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag) Procedures2(org.eclipse.collections.impl.block.factory.Procedures2) Function(org.eclipse.collections.api.block.function.Function) Predicate(org.eclipse.collections.api.block.predicate.Predicate) Verify(org.eclipse.collections.impl.test.Verify) CheckedPredicate(org.eclipse.collections.impl.block.predicate.checked.CheckedPredicate) MutableList(org.eclipse.collections.api.list.MutableList) ParallelIterable(org.eclipse.collections.api.ParallelIterable) RichIterable(org.eclipse.collections.api.RichIterable) Function0(org.eclipse.collections.api.block.function.Function0) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Function2(org.eclipse.collections.api.block.function.Function2) CheckedFunction(org.eclipse.collections.impl.block.function.checked.CheckedFunction) After(org.junit.After) Tuples(org.eclipse.collections.impl.tuple.Tuples) ParallelListIterable(org.eclipse.collections.api.list.ParallelListIterable) Interval(org.eclipse.collections.impl.list.Interval) NoSuchElementException(java.util.NoSuchElementException) Pair(org.eclipse.collections.api.tuple.Pair) DoubleFunction(org.eclipse.collections.api.block.function.primitive.DoubleFunction) MutableCollection(org.eclipse.collections.api.collection.MutableCollection) ExecutorService(java.util.concurrent.ExecutorService) Comparators(org.eclipse.collections.impl.block.factory.Comparators) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Before(org.junit.Before) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) CollectionAddProcedure(org.eclipse.collections.impl.block.procedure.CollectionAddProcedure) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) CheckedProcedure(org.eclipse.collections.impl.block.procedure.checked.CheckedProcedure) IOException(java.io.IOException) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) Executors(java.util.concurrent.Executors) ExecutionException(java.util.concurrent.ExecutionException) ParallelSetIterable(org.eclipse.collections.api.set.ParallelSetIterable) ImmutableList(org.eclipse.collections.api.list.ImmutableList) Lists(org.eclipse.collections.impl.factory.Lists) Pattern(java.util.regex.Pattern) Assert(org.junit.Assert) FloatFunction(org.eclipse.collections.api.block.function.primitive.FloatFunction) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Pattern (java.util.regex.Pattern)1 ParallelIterable (org.eclipse.collections.api.ParallelIterable)1 RichIterable (org.eclipse.collections.api.RichIterable)1 Function (org.eclipse.collections.api.block.function.Function)1 Function0 (org.eclipse.collections.api.block.function.Function0)1 Function2 (org.eclipse.collections.api.block.function.Function2)1 DoubleFunction (org.eclipse.collections.api.block.function.primitive.DoubleFunction)1 FloatFunction (org.eclipse.collections.api.block.function.primitive.FloatFunction)1 Predicate (org.eclipse.collections.api.block.predicate.Predicate)1 MutableCollection (org.eclipse.collections.api.collection.MutableCollection)1 ImmutableList (org.eclipse.collections.api.list.ImmutableList)1 MutableList (org.eclipse.collections.api.list.MutableList)1 ParallelListIterable (org.eclipse.collections.api.list.ParallelListIterable)1 ParallelSetIterable (org.eclipse.collections.api.set.ParallelSetIterable)1