use of org.eclipse.collections.impl.math.Sum in project eclipse-collections by eclipse.
the class TakeWhileIterableTest method iterator.
@Override
@Test
public void iterator() {
Sum sum1 = new IntegerSum(0);
for (Integer each : this.takeWhileIterable) {
sum1.add(each);
}
Assert.assertEquals(3, sum1.getValue().intValue());
Sum sum2 = new IntegerSum(0);
for (Integer each : this.emptyListTakeWhileIterable) {
sum2.add(each);
}
Assert.assertEquals(0, sum2.getValue().intValue());
Sum sum3 = new IntegerSum(0);
for (Integer each : this.alwaysFalseTakeWhileIterable) {
sum3.add(each);
}
Assert.assertEquals(0, sum3.getValue().intValue());
Sum sum5 = new IntegerSum(0);
for (Integer each : this.alwaysTrueTakeWhileIterable) {
sum5.add(each);
}
Assert.assertEquals(15, sum5.getValue().intValue());
}
use of org.eclipse.collections.impl.math.Sum in project eclipse-collections by eclipse.
the class ArrayListIterateTest method injectIntoWithOver100.
@Test
public void injectIntoWithOver100() {
Sum result = new IntegerSum(0);
Integer parameter = 2;
Function3<Sum, Integer, Integer, Sum> function = (sum, element, withValue) -> sum.add((element.intValue() - element.intValue()) * withValue.intValue());
Sum sumOfDoubledValues = ArrayListIterate.injectIntoWith(result, this.getOver100IntegerList(), function, parameter);
Assert.assertEquals(0, sumOfDoubledValues.getValue().intValue());
}
use of org.eclipse.collections.impl.math.Sum in project eclipse-collections by eclipse.
the class IterateTest method injectIntoWithRandomAccess.
@Test
public void injectIntoWithRandomAccess() {
Sum result = new IntegerSum(0);
Integer parameter = 2;
MutableList<Integer> integers = Interval.oneTo(5).toList().asSynchronized();
this.basicTestDoubleSum(result, integers, parameter);
}
use of org.eclipse.collections.impl.math.Sum 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);
}
use of org.eclipse.collections.impl.math.Sum 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());
});
}
Aggregations