use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class AbstractMutableBooleanValuesMap 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 ObjectBooleanHashMapWithHashingStrategy 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 BooleanHashBag method select.
@Override
public MutableBooleanBag select(BooleanPredicate predicate) {
MutableBooleanBag result = new BooleanHashBag();
this.forEachWithOccurrences((each, occurrences) -> {
if (predicate.accept(each)) {
result.addOccurrences(each, occurrences);
}
});
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class BooleanHashBag method selectByOccurrences.
@Override
public MutableBooleanBag selectByOccurrences(IntPredicate predicate) {
MutableBooleanBag result = new BooleanHashBag();
this.forEachWithOccurrences((each, occurrences) -> {
if (predicate.accept(occurrences)) {
result.addOccurrences(each, occurrences);
}
});
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.
the class SynchronizedBooleanBagTest method asSynchronized.
@Override
@Test
public void asSynchronized() {
super.asSynchronized();
SynchronizedBooleanBag bagWithLockObject = new SynchronizedBooleanBag(BooleanHashBag.newBagWith(true, false, true), new Object());
Assert.assertSame(bagWithLockObject, bagWithLockObject.asSynchronized());
Assert.assertEquals(bagWithLockObject, bagWithLockObject.asSynchronized());
MutableBooleanBag bag = this.classUnderTest();
Assert.assertSame(bag, bag.asSynchronized());
Assert.assertEquals(bag, bag.asSynchronized());
}
Aggregations