use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class LazyBooleanIterableAdapterTest method booleanIterator.
@Test
public void booleanIterator() {
int sum = 0;
for (BooleanIterator iterator = this.iterable.booleanIterator(); iterator.hasNext(); ) {
sum += iterator.next() ? 1 : 0;
}
Assert.assertEquals(2, sum);
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ReverseBooleanIterableTest method iterator_throws.
@Test(expected = NoSuchElementException.class)
public void iterator_throws() {
BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
BooleanIterator iterator = iterable.booleanIterator();
while (iterator.hasNext()) {
iterator.next();
}
iterator.next();
}
use of org.eclipse.collections.api.iterator.BooleanIterator 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.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class AbstractImmutableBooleanListTestCase method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanIterator iterator = this.classUnderTest().booleanIterator();
for (int i = 0; iterator.hasNext(); i++) {
Assert.assertEquals(i % 2 == 0, iterator.next());
}
Assert.assertFalse(iterator.hasNext());
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class BooleanHashBag method addAll.
@Override
public boolean addAll(BooleanIterable source) {
if (source.isEmpty()) {
return false;
}
if (source instanceof BooleanBag) {
BooleanBag otherBag = (BooleanBag) source;
otherBag.forEachWithOccurrences(this::addOccurrences);
} else {
BooleanIterator iterator = source.booleanIterator();
while (iterator.hasNext()) {
boolean each = iterator.next();
this.add(each);
}
}
return true;
}
Aggregations