use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class BooleanHashBag method injectInto.
@Override
public <T> T injectInto(T injectedValue, ObjectBooleanToObjectFunction<? super T, ? extends T> function) {
T result = injectedValue;
BooleanIterator it = this.booleanIterator();
while (it.hasNext()) {
result = function.valueOf(result, it.next());
}
return result;
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class AbstractBooleanSetTestCase 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.setWithFalse.booleanIterator();
Assert.assertTrue(booleanIterator1.hasNext());
Assert.assertFalse(booleanIterator1.next());
Assert.assertFalse(booleanIterator1.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) booleanIterator1::next);
BooleanIterator booleanIterator2 = this.setWithTrue.booleanIterator();
Assert.assertTrue(booleanIterator2.hasNext());
Assert.assertTrue(booleanIterator2.next());
Assert.assertFalse(booleanIterator2.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) booleanIterator2::next);
BooleanIterator booleanIterator3 = this.setWithTrueFalse.booleanIterator();
BooleanHashSet actual = new BooleanHashSet();
Assert.assertTrue(booleanIterator3.hasNext());
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 BooleanHashBagTest method booleanIterator.
@Override
@Test
public void booleanIterator() {
super.booleanIterator();
BooleanHashBag bag = this.newWith(true, false, false, true, true, true);
BooleanIterator iterator = bag.booleanIterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertFalse(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertFalse(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(iterator.next());
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method iterator_throws_non_empty_collection.
@Test(expected = NoSuchElementException.class)
public void iterator_throws_non_empty_collection() {
BooleanIterable iterable = this.newWith(true, true, true);
BooleanIterator iterator = iterable.booleanIterator();
while (iterator.hasNext()) {
Assert.assertTrue(iterator.next());
}
iterator.next();
}
use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.
the class SynchronizedBooleanIterableTest method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanIterable iterable = this.newWith(true, true, false, false);
BooleanArrayList list = BooleanArrayList.newListWith(true, true, false, false);
BooleanIterator iterator = iterable.booleanIterator();
for (int i = 0; i < 4; i++) {
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(list.remove(iterator.next()));
}
Verify.assertEmpty(list);
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
Aggregations