use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class SelectBooleanIterableTest method injectInto.
@Test
public void injectInto() {
MutableInteger result = this.iterable.injectInto(new MutableInteger(0), (object, value) -> object.add(value ? 1 : 0));
Assert.assertEquals(new MutableInteger(2), result);
}
use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class TapBooleanIterableTest method injectInto.
@Test
public void injectInto() {
StringBuilder concat = new StringBuilder();
TapBooleanIterable iterable = new TapBooleanIterable(this.list, concat::append);
MutableInteger result = iterable.injectInto(new MutableInteger(0), (object, value) -> object.add(value ? 1 : 0));
Assert.assertEquals(new MutableInteger(2), result);
Assert.assertEquals("truefalsefalsetrue", concat.toString());
}
use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class AbstractBooleanSetTestCase 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 AbstractBooleanIterableTestCase method injectInto.
@Test
public void injectInto() {
BooleanIterable iterable = this.newWith(true, false, true);
MutableInteger result = iterable.injectInto(new MutableInteger(0), (object, value) -> object.add(value ? 1 : 0));
Assert.assertEquals(new MutableInteger(2), result);
}
use of org.eclipse.collections.impl.math.MutableInteger in project eclipse-collections by eclipse.
the class IntIntervalTest method injectIntoWithIndex.
@Test
public void injectIntoWithIndex() {
IntInterval interval1 = IntInterval.oneTo(3);
MutableInteger result1 = this.intInterval.injectIntoWithIndex(new MutableInteger(0), (object, value, index) -> object.add(value * interval1.get(index)));
Assert.assertEquals(new MutableInteger(14), result1);
IntInterval interval2 = IntInterval.fromTo(3, 1);
MutableInteger result2 = interval2.injectIntoWithIndex(new MutableInteger(0), (object, value, index) -> object.add(value * this.intInterval.get(index)));
Assert.assertEquals(new MutableInteger(10), result2);
}
Aggregations