use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method iterator.
@Test
public void iterator() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
BooleanIterator iterator = iterable.booleanIterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertFalse(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertFalse(iterator.next());
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method contains.
@Test
public void contains() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false).asReversed();
Assert.assertTrue(iterable.contains(false));
Assert.assertFalse(iterable.contains(true));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method isEmpty.
@Test
public void isEmpty() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
Verify.assertEmpty(new BooleanArrayList().asReversed());
Verify.assertNotEmpty(iterable);
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method collectBoolean.
@Test
public void collectBoolean() {
BooleanIterable result = this.newWith(1, 0).collectBoolean(PrimitiveFunctions.integerIsPositive());
Assert.assertEquals(BooleanBags.mutable.of(true, false), result.toBag());
Assert.assertEquals(BooleanBags.mutable.of(true, false), BooleanBags.mutable.ofAll(result));
}
use of org.eclipse.collections.api.BooleanIterable 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;
}
Aggregations