use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ImmutableFalseSet method newWithAll.
@Override
public ImmutableBooleanSet newWithAll(BooleanIterable elements) {
ImmutableBooleanSet result = this;
BooleanIterator booleanIterator = elements.booleanIterator();
while (booleanIterator.hasNext()) {
result = result.newWith(booleanIterator.next());
}
return result;
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ImmutableTrueFalseSet method newWithoutAll.
@Override
public ImmutableBooleanSet newWithoutAll(BooleanIterable elements) {
ImmutableBooleanSet result = this;
BooleanIterator booleanIterator = elements.booleanIterator();
while (booleanIterator.hasNext()) {
result = result.newWithout(booleanIterator.next());
}
return result;
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class ImmutableBooleanHashSetTest method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanIterator booleanIterator0 = this.emptySet.booleanIterator();
Assert.assertFalse(booleanIterator0.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) booleanIterator0::next);
BooleanIterator booleanIterator1 = this.falseSet.booleanIterator();
Assert.assertTrue(booleanIterator1.hasNext());
Assert.assertFalse(booleanIterator1.next());
Assert.assertFalse(booleanIterator1.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) booleanIterator1::next);
BooleanIterator booleanIterator2 = this.trueSet.booleanIterator();
Assert.assertTrue(booleanIterator2.hasNext());
Assert.assertTrue(booleanIterator2.next());
Assert.assertFalse(booleanIterator2.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) booleanIterator2::next);
BooleanIterator booleanIterator3 = this.trueFalseSet.booleanIterator();
Assert.assertTrue(booleanIterator3.hasNext());
BooleanHashSet actual = new BooleanHashSet();
actual.add(booleanIterator3.next());
Assert.assertTrue(booleanIterator3.hasNext());
actual.add(booleanIterator3.next());
Assert.assertEquals(BooleanHashSet.newSetWith(true, false), actual);
Assert.assertFalse(booleanIterator3.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) booleanIterator3::next);
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class AbstractBooleanStackTestCase method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanIterator iterator = this.classUnderTest().booleanIterator();
int size = this.classUnderTest().size();
for (int i = 0; i < size; i++) {
Assert.assertTrue(iterator.hasNext());
boolean sizeEven = (size & 1) == 0;
boolean iEven = (i & 1) == 0;
Assert.assertEquals(sizeEven != iEven, iterator.next());
}
Assert.assertFalse(iterator.hasNext());
Assert.assertEquals((this.classUnderTest().size() & 1) != 0, this.classUnderTest().booleanIterator().next());
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class CollectBooleanIterableTest method iterator.
@Test
public void iterator() {
long count = 0;
long isTrueCount = 0;
BooleanIterator iterator = this.booleanIterable.booleanIterator();
while (iterator.hasNext()) {
count++;
if (iterator.next()) {
isTrueCount++;
}
}
Assert.assertEquals(3L, count);
Assert.assertEquals(2L, isTrueCount);
}
Aggregations