use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class AbstractLazyIterableTestCase method collectBooleanWithTarget.
@Test
public void collectBooleanWithTarget() {
MutableBooleanCollection target = new BooleanArrayList();
MutableBooleanCollection result = this.lazyIterable.collectBoolean(PrimitiveFunctions.integerIsPositive(), target);
Assert.assertEquals(BooleanArrayList.newListWith(true, true, true, true, true, true, true), result.toList());
Assert.assertSame("Target list sent as parameter not returned", target, result);
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class ImmutableBooleanArrayList method distinct.
/**
* @since 6.0
*/
@Override
public ImmutableBooleanList distinct() {
BooleanArrayList target = new BooleanArrayList();
MutableBooleanSet seenSoFar = new BooleanHashSet();
for (int i = 0; i < this.size; i++) {
boolean each = this.get(i);
if (seenSoFar.add(each)) {
target.add(each);
}
}
return target.toImmutable();
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method collectBooleanWithTarget.
@Test
public void collectBooleanWithTarget() {
MutableBooleanCollection target = new BooleanArrayList();
BooleanIterable result = this.newWith(1, 0).collectBoolean(PrimitiveFunctions.integerIsPositive(), target);
Assert.assertSame("Target list sent as parameter not returned", target, result);
Assert.assertEquals(BooleanBags.mutable.of(true, false), result.toBag());
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectBooleanWithTargetOverOptimizeLimit.
@Test
public void collectBooleanWithTargetOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableBooleanList target = new BooleanArrayList();
MutableBooleanList actual = ArrayListIterate.collectBoolean(list, PrimitiveFunctions.integerIsPositive(), target);
BooleanArrayList expected = new BooleanArrayList(list.size());
expected.add(false);
for (int i = 1; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add(true);
}
Assert.assertEquals(expected, actual);
Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectBooleanWithTarget.
@Test
public void collectBooleanWithTarget() {
ArrayList<Integer> list = this.createIntegerList();
MutableBooleanList target = new BooleanArrayList();
MutableBooleanList actual = ArrayListIterate.collectBoolean(list, PrimitiveFunctions.integerIsPositive(), target);
Assert.assertSame("Target list sent as parameter not returned", target, actual);
Assert.assertEquals(BooleanArrayList.newListWith(false, false, true), actual);
}
Aggregations