use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ObjectBooleanHashMapValuesTestCase method reject.
@Override
@Test
public void reject() {
BooleanIterable iterable = this.classUnderTest();
Verify.assertSize(1, iterable.reject(BooleanPredicates.isTrue()));
Verify.assertSize(2, iterable.reject(BooleanPredicates.isFalse()));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ObjectBooleanHashMapValuesTestCase method chunk.
@Override
public void chunk() {
BooleanIterable iterable1 = this.newWith(true);
Verify.assertIterablesEqual(Lists.mutable.with(BooleanBags.mutable.with(true)).toSet(), iterable1.chunk(1).toSet());
BooleanIterable iterable2 = this.newWith(false);
Verify.assertIterablesEqual(Lists.mutable.with(BooleanBags.mutable.with(false)).toSet(), iterable2.chunk(1).toSet());
BooleanIterable iterable3 = this.newWith(false, true);
Verify.assertIterablesEqual(Lists.mutable.with(BooleanBags.mutable.with(false), BooleanBags.mutable.with(true)).toSet(), iterable3.chunk(1).toSet());
Verify.assertIterablesEqual(Lists.mutable.with(BooleanBags.mutable.with(false, true)), iterable3.chunk(2));
Verify.assertIterablesEqual(Lists.mutable.with(BooleanBags.mutable.with(false, true)), iterable3.chunk(3));
Verify.assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().chunk(0));
Verify.assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().chunk(-1));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ObjectBooleanHashMapValuesTestCase method select.
@Override
@Test
public void select() {
BooleanIterable iterable = this.classUnderTest();
Verify.assertSize(1, iterable.select(BooleanPredicates.isFalse()));
Verify.assertSize(2, iterable.select(BooleanPredicates.isTrue()));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ImmutableBooleanArrayList 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(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.toImmutable());
}
}
}
return result.toImmutable();
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method newCollectionWith.
@Test
public void newCollectionWith() {
BooleanIterable iterable = this.newWith(true, false, true);
Verify.assertSize(3, iterable);
Assert.assertTrue(iterable.containsAll(true, false, true));
BooleanIterable iterable1 = this.newWith();
Verify.assertEmpty(iterable1);
Assert.assertFalse(iterable1.containsAll(true, false, true));
BooleanIterable iterable2 = this.newWith(true);
Verify.assertSize(1, iterable2);
Assert.assertFalse(iterable2.containsAll(true, false, true));
Assert.assertTrue(iterable2.containsAll(true, true));
}
Aggregations