use of org.eclipse.collections.api.iterator.BooleanIterator 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.iterator.BooleanIterator 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.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class BooleanArrayList 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(BooleanLists.mutable.withAll(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);
}
}
}
return result;
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class AbstractImmutableBooleanBagTestCase method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanHashBag bag = BooleanHashBag.newBagWith();
BooleanIterator iterator = this.classUnderTest().booleanIterator();
for (int i = 0; i < this.classUnderTest().size(); i++) {
Assert.assertTrue(iterator.hasNext());
bag.add(iterator.next());
}
Assert.assertEquals(bag, this.classUnderTest());
Assert.assertFalse(iterator.hasNext());
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ImmutableBooleanEmptyStackTest method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanIterator iterator = this.classUnderTest().booleanIterator();
Assert.assertFalse(iterator.hasNext());
}
Aggregations