use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.
the class ImmutableBooleanArrayList method chunk.
@Override
public RichIterable<BooleanIterable> chunk(int size) {
if (size <= 0) {
throw new IllegalArgumentException("Size for groups must be positive but was: " + size);
}
MutableList<BooleanIterable> result = Lists.mutable.empty();
if (this.notEmpty()) {
if (this.size() <= size) {
result.add(this);
} else {
BooleanIterator iterator = this.booleanIterator();
while (iterator.hasNext()) {
MutableBooleanList batch = BooleanLists.mutable.empty();
for (int i = 0; i < size && iterator.hasNext(); i++) {
batch.add(iterator.next());
}
result.add(batch.toImmutable());
}
}
}
return result.toImmutable();
}
use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.
the class ImmutableBooleanArrayList method newWithoutAll.
@Override
public ImmutableBooleanList newWithoutAll(BooleanIterable elements) {
MutableBooleanList list = this.toList();
list.removeAll(elements);
return list.toImmutable();
}
use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.
the class BooleanCaseProcedureTest method oneCaseWithDefault.
@Test
public void oneCaseWithDefault() {
MutableBooleanList ifOneList = BooleanLists.mutable.empty();
MutableBooleanList defaultList = BooleanLists.mutable.empty();
MutableBooleanList list = BooleanLists.mutable.with(true, false);
BooleanCaseProcedure procedure = new BooleanCaseProcedure(defaultList::add).addCase(value -> value, ifOneList::add);
list.each(procedure);
Assert.assertEquals(BooleanLists.mutable.with(true), ifOneList);
Assert.assertEquals(BooleanLists.mutable.with(false), defaultList);
}
use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.
the class BooleanCaseProcedureTest method twoCasesNoDefault.
@Test
public void twoCasesNoDefault() {
MutableBooleanList ifTrueList = BooleanLists.mutable.empty();
MutableBooleanList ifFalseList = BooleanLists.mutable.empty();
MutableBooleanList list = BooleanLists.mutable.with(true, false);
BooleanCaseProcedure procedure = new BooleanCaseProcedure().addCase(value -> value, ifTrueList::add).addCase(value -> !value, ifFalseList::add);
list.each(procedure);
Assert.assertEquals(BooleanLists.mutable.with(true), ifTrueList);
Assert.assertEquals(BooleanLists.mutable.with(false), ifFalseList);
Verify.assertContains("BooleanCaseProcedure", procedure.toString());
}
Aggregations