use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class IntIntervalTest method injectInto.
@Test
public void injectInto() {
IntInterval intInterval1 = IntInterval.oneTo(3);
MutableInteger result = intInterval1.injectInto(new MutableInteger(0), MutableInteger::add);
Assert.assertEquals(new MutableInteger(6), result);
IntInterval intInterval2 = IntInterval.fromTo(3, 1);
MutableInteger result2 = intInterval2.injectInto(new MutableInteger(0), MutableInteger::add);
Assert.assertEquals(new MutableInteger(6), result2);
}
use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class AbstractImmutableBooleanListTestCase method injectIntoWithIndex.
@Test
public void injectIntoWithIndex() {
ImmutableBooleanList list = this.newWith(true, false, true);
MutableInteger result = list.injectIntoWithIndex(new MutableInteger(0), (object, value, index) -> object.add((value ? 1 : 0) + index));
Assert.assertEquals(new MutableInteger(5), result);
}
use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class ImmutableBooleanHashSetTest method injectInto.
@Override
@Test
public void injectInto() {
ObjectBooleanToObjectFunction<MutableInteger, MutableInteger> function = (object, value) -> object.add(value ? 1 : 0);
Assert.assertEquals(new MutableInteger(1), BooleanHashSet.newSetWith(true, false, true).injectInto(new MutableInteger(0), function));
Assert.assertEquals(new MutableInteger(1), BooleanHashSet.newSetWith(true).injectInto(new MutableInteger(0), function));
Assert.assertEquals(new MutableInteger(0), BooleanHashSet.newSetWith(false).injectInto(new MutableInteger(0), function));
Assert.assertEquals(new MutableInteger(0), new BooleanHashSet().injectInto(new MutableInteger(0), function));
}
use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class AbstractBooleanListTestCase method injectIntoWithIndex.
@Test
public void injectIntoWithIndex() {
MutableBooleanList list = this.newWith(true, false, true);
MutableInteger result = list.injectIntoWithIndex(new MutableInteger(0), (object, value, index) -> object.add((value ? 1 : 0) + index));
Assert.assertEquals(new MutableInteger(5), result);
}
Aggregations