use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class BooleanHashBag method removeAll.
@Override
public boolean removeAll(BooleanIterable source) {
if (source.isEmpty()) {
return false;
}
int oldSize = this.size();
if (source instanceof BooleanBag) {
BooleanBag otherBag = (BooleanBag) source;
otherBag.forEachWithOccurrences((each, occurrences) -> {
if (each) {
this.trueCount = 0;
} else {
this.falseCount = 0;
}
});
} else {
BooleanIterator iterator = source.booleanIterator();
while (iterator.hasNext()) {
boolean each = iterator.next();
if (each) {
this.trueCount = 0;
} else {
this.falseCount = 0;
}
}
}
return this.size() != oldSize;
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class BooleanHashBag 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(BooleanBags.mutable.withAll(this));
} else {
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.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class BooleanArrayStack method writeExternal.
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(this.size());
BooleanIterator iterator = this.delegate.asReversed().booleanIterator();
while (iterator.hasNext()) {
boolean each = iterator.next();
out.writeBoolean(each);
}
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ImmutableObjectBooleanEmptyMapTest method iterator.
@Override
@Test
public void iterator() {
BooleanIterator iterator = this.classUnderTest().booleanIterator();
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ImmutableObjectBooleanSingletonMapTest method iterator.
@Override
@Test
public void iterator() {
BooleanIterator iterator = this.classUnderTest().booleanIterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(iterator.next());
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
Aggregations