Search in sources :

Example 6 with BooleanIterator

use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.

the class AbstractMutableBooleanValuesMap 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 : AbstractBooleanIterable(org.eclipse.collections.impl.primitive.AbstractBooleanIterable) 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)

Example 7 with BooleanIterator

use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.

the class ObjectBooleanHashMapWithHashingStrategy 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 8 with BooleanIterator

use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.

the class BooleanArrayList 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()) {
        if (this.size() <= size) {
            result.add(BooleanLists.mutable.withAll(this));
        } else {
            BooleanIterator iterator = this.booleanIterator();
            while (iterator.hasNext()) {
                MutableBooleanList batch = BooleanLists.mutable.empty();
                for (int i = 0; i < size && iterator.hasNext(); i++) {
                    batch.add(iterator.next());
                }
                result.add(batch);
            }
        }
    }
    return result;
}
Also used : ReverseBooleanIterable(org.eclipse.collections.impl.lazy.primitive.ReverseBooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) BooleanIterable(org.eclipse.collections.api.BooleanIterable) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator)

Example 9 with BooleanIterator

use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanBagTestCase method booleanIterator.

@Override
@Test
public void booleanIterator() {
    BooleanHashBag bag = BooleanHashBag.newBagWith();
    BooleanIterator iterator = this.classUnderTest().booleanIterator();
    for (int i = 0; i < this.classUnderTest().size(); i++) {
        Assert.assertTrue(iterator.hasNext());
        bag.add(iterator.next());
    }
    Assert.assertEquals(bag, this.classUnderTest());
    Assert.assertFalse(iterator.hasNext());
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Example 10 with BooleanIterator

use of org.eclipse.collections.api.iterator.BooleanIterator in project eclipse-collections by eclipse.

the class ImmutableBooleanEmptyStackTest method booleanIterator.

@Override
@Test
public void booleanIterator() {
    BooleanIterator iterator = this.classUnderTest().booleanIterator();
    Assert.assertFalse(iterator.hasNext());
}
Also used : 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