Search in sources :

Example 31 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class ImmutableBooleanEmptyListTest method reject.

@Override
@Test
public void reject() {
    super.reject();
    BooleanIterable iterable = this.classUnderTest();
    Verify.assertEmpty(iterable.reject(BooleanPredicates.isTrue()));
    BooleanIterable booleanIterable = iterable.reject(BooleanPredicates.isFalse());
    Verify.assertEmpty(booleanIterable);
    Assert.assertSame(iterable, booleanIterable);
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) Test(org.junit.Test)

Example 32 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class ObjectBooleanHashMap 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;
}
Also used : LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) BooleanIterable(org.eclipse.collections.api.BooleanIterable) MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator)

Example 33 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class CollectBooleanIterableTest method containsAllIterable.

@Test
public void containsAllIterable() {
    BooleanIterable booleanIterable = Interval.oneTo(3).collectBoolean(PrimitiveFunctions.integerIsPositive());
    Assert.assertTrue(booleanIterable.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertTrue(booleanIterable.containsAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertFalse(booleanIterable.containsAll(BooleanArrayList.newListWith(false)));
    Assert.assertFalse(booleanIterable.containsAll(BooleanArrayList.newListWith(false, false)));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Test(org.junit.Test)

Example 34 with BooleanIterable

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

Example 35 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class ReverseBooleanIterableTest method reject.

@Test
public void reject() {
    BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
    Verify.assertSize(1, iterable.reject(BooleanPredicates.equal(false)));
    Verify.assertSize(2, iterable.reject(BooleanPredicates.equal(true)));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) Test(org.junit.Test)

Aggregations

BooleanIterable (org.eclipse.collections.api.BooleanIterable)54 Test (org.junit.Test)47 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)27 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)11 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)8 MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)4 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)4 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)2 ReverseBooleanIterable (org.eclipse.collections.impl.lazy.primitive.ReverseBooleanIterable)2 NoSuchElementException (java.util.NoSuchElementException)1 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)1 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)1 BooleanPredicates (org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates)1 FastList (org.eclipse.collections.impl.list.mutable.FastList)1 MutableInteger (org.eclipse.collections.impl.math.MutableInteger)1 AbstractBooleanIterable (org.eclipse.collections.impl.primitive.AbstractBooleanIterable)1 SynchronizedBooleanIterable (org.eclipse.collections.impl.primitive.SynchronizedBooleanIterable)1 BooleanHashSet (org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1