use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class ObjectBooleanHashMap 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()) {
BooleanIterator iterator = this.booleanIterator();
while (iterator.hasNext()) {
MutableBooleanBag batch = BooleanBags.mutable.empty();
for (int i = 0; i < size && iterator.hasNext(); i++) {
batch.add(iterator.next());
}
result.add(batch);
}
}
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class AbstractImmutableMap method collectBoolean.
@Override
public ImmutableBooleanBag collectBoolean(BooleanFunction<? super V> booleanFunction) {
MutableBooleanBag result = new BooleanHashBag();
this.forEach(new CollectBooleanProcedure<>(booleanFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class AbstractMutableMap method collectBoolean.
@Override
public MutableBooleanBag collectBoolean(BooleanFunction<? super V> booleanFunction) {
MutableBooleanBag result = new BooleanHashBag();
this.forEach(new CollectBooleanProcedure<>(booleanFunction, result));
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class AbstractMutableBooleanBagTestCase method allSatisfy.
@Override
@Test
public void allSatisfy() {
super.allSatisfy();
int[] count = { 0 };
MutableBooleanBag bag = this.newWith(false, true, false);
Assert.assertFalse(bag.allSatisfy(value -> {
count[0]++;
return !value;
}));
Assert.assertEquals(2L, count[0]);
}
use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class AbstractMutableBooleanBagTestCase method addAllIterable.
@Override
@Test
public void addAllIterable() {
super.addAllIterable();
MutableBooleanBag bag = this.newWith();
Assert.assertTrue(bag.addAll(BooleanArrayList.newListWith(true, false, true, false, true)));
Assert.assertFalse(bag.addAll(new BooleanArrayList()));
Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true), bag);
Assert.assertTrue(bag.addAll(BooleanHashBag.newBagWith(true, false, true, false, true)));
Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false, false, true, true, true, true, true, true), bag);
}
Aggregations