Search in sources :

Example 11 with BooleanIterator

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;
}
Also used : BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator)

Example 12 with BooleanIterator

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);
}
Also used : BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Example 13 with BooleanIterator

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);
}
Also used : BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Example 14 with BooleanIterator

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();
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Example 15 with BooleanIterator

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);
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) SynchronizedBooleanIterable(org.eclipse.collections.impl.primitive.SynchronizedBooleanIterable) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Aggregations

BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)39 Test (org.junit.Test)22 BooleanIterable (org.eclipse.collections.api.BooleanIterable)10 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)10 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)7 MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)6 ImmutableBooleanSet (org.eclipse.collections.api.set.primitive.ImmutableBooleanSet)5 BooleanBag (org.eclipse.collections.api.bag.primitive.BooleanBag)2 ImmutableBooleanBag (org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag)2 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)2 ReverseBooleanIterable (org.eclipse.collections.impl.lazy.primitive.ReverseBooleanIterable)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 BitSet (java.util.BitSet)1 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)1 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)1 ImmutableEmptyBooleanIterator (org.eclipse.collections.impl.iterator.ImmutableEmptyBooleanIterator)1 UnmodifiableBooleanIterator (org.eclipse.collections.impl.iterator.UnmodifiableBooleanIterator)1 AbstractBooleanIterable (org.eclipse.collections.impl.primitive.AbstractBooleanIterable)1 SynchronizedBooleanIterable (org.eclipse.collections.impl.primitive.SynchronizedBooleanIterable)1