Search in sources :

Example 21 with IntegerSum

use of org.eclipse.collections.impl.math.IntegerSum in project eclipse-collections by eclipse.

the class IterateTest method injectIntoWith.

@Test
public void injectIntoWith() {
    Sum result = new IntegerSum(0);
    Integer parameter = 2;
    MutableList<Integer> integers = Interval.oneTo(5).toList();
    this.basicTestDoubleSum(result, integers, parameter);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BigInteger(java.math.BigInteger) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Sum(org.eclipse.collections.impl.math.Sum) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Test(org.junit.Test)

Example 22 with IntegerSum

use of org.eclipse.collections.impl.math.IntegerSum in project eclipse-collections by eclipse.

the class IterateTest method forEachWith.

@Test
public void forEachWith() {
    this.iterables.each(each -> {
        Sum result = new IntegerSum(0);
        Iterate.forEachWith(each, (integer, parm) -> result.add(integer.intValue() * parm.intValue()), 2);
        Assert.assertEquals(30, result.getValue().intValue());
    });
}
Also used : IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Sum(org.eclipse.collections.impl.math.Sum) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Test(org.junit.Test)

Example 23 with IntegerSum

use of org.eclipse.collections.impl.math.IntegerSum in project eclipse-collections by eclipse.

the class IterateTest method injectIntoWithHashSet.

@Test
public void injectIntoWithHashSet() {
    Sum result = new IntegerSum(0);
    Integer parameter = 2;
    MutableSet<Integer> integers = Interval.toSet(1, 5);
    this.basicTestDoubleSum(result, integers, parameter);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BigInteger(java.math.BigInteger) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Sum(org.eclipse.collections.impl.math.Sum) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Test(org.junit.Test)

Example 24 with IntegerSum

use of org.eclipse.collections.impl.math.IntegerSum in project eclipse-collections by eclipse.

the class LazyIterateTest method selectForEachWith.

@Test
public void selectForEachWith() {
    LazyIterable<Integer> select = LazyIterate.select(Interval.oneTo(5), Predicates.lessThan(5));
    Sum sum = new IntegerSum(0);
    select.forEachWith((each, aSum) -> aSum.add(each), sum);
    Assert.assertEquals(10, sum.getValue().intValue());
}
Also used : IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Sum(org.eclipse.collections.impl.math.Sum) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Test(org.junit.Test)

Example 25 with IntegerSum

use of org.eclipse.collections.impl.math.IntegerSum in project eclipse-collections by eclipse.

the class LazyIterateTest method rejectForEachWith.

@Test
public void rejectForEachWith() {
    LazyIterable<Integer> select = LazyIterate.reject(Interval.oneTo(5), Predicates.lessThan(5));
    Sum sum = new IntegerSum(0);
    select.forEachWith((each, aSum) -> aSum.add(each), sum);
    Assert.assertEquals(5, sum.getValue().intValue());
}
Also used : IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Sum(org.eclipse.collections.impl.math.Sum) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) Test(org.junit.Test)

Aggregations

IntegerSum (org.eclipse.collections.impl.math.IntegerSum)93 Sum (org.eclipse.collections.impl.math.Sum)85 Test (org.junit.Test)79 BatchIterable (org.eclipse.collections.impl.parallel.BatchIterable)20 Map (java.util.Map)16 MutableMap (org.eclipse.collections.api.map.MutableMap)16 ObjectIntProcedure (org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure)10 FastList (org.eclipse.collections.impl.list.mutable.FastList)10 Assert (org.junit.Assert)10 Interval (org.eclipse.collections.impl.list.Interval)9 UnifiedMap (org.eclipse.collections.impl.map.mutable.UnifiedMap)9 HashMap (java.util.HashMap)8 ImmutableEntry (org.eclipse.collections.impl.tuple.ImmutableEntry)8 LazyIterable (org.eclipse.collections.api.LazyIterable)7 Predicates (org.eclipse.collections.impl.block.factory.Predicates)7 BigInteger (java.math.BigInteger)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Procedure2 (org.eclipse.collections.api.block.procedure.Procedure2)6 Verify (org.eclipse.collections.impl.test.Verify)6 ArrayList (java.util.ArrayList)4