use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method forEach.
@Test
public void forEach() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
boolean[] result = { true };
iterable.forEach(each -> result[0] &= each);
Assert.assertFalse(result[0]);
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method empty.
@Test
public void empty() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
Assert.assertTrue(iterable.notEmpty());
Verify.assertNotEmpty(iterable);
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method select.
@Test
public void select() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
Verify.assertSize(2, iterable.select(BooleanPredicates.equal(false)));
Verify.assertSize(1, iterable.select(BooleanPredicates.equal(true)));
}
use of org.eclipse.collections.api.BooleanIterable 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.BooleanIterable 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;
}
Aggregations