Search in sources :

Example 1 with MutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag 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 2 with MutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag 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 3 with MutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.

the class BooleanHashBag method select.

@Override
public MutableBooleanBag select(BooleanPredicate predicate) {
    MutableBooleanBag result = new BooleanHashBag();
    this.forEachWithOccurrences((each, occurrences) -> {
        if (predicate.accept(each)) {
            result.addOccurrences(each, occurrences);
        }
    });
    return result;
}
Also used : MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag)

Example 4 with MutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.

the class BooleanHashBag method selectByOccurrences.

@Override
public MutableBooleanBag selectByOccurrences(IntPredicate predicate) {
    MutableBooleanBag result = new BooleanHashBag();
    this.forEachWithOccurrences((each, occurrences) -> {
        if (predicate.accept(occurrences)) {
            result.addOccurrences(each, occurrences);
        }
    });
    return result;
}
Also used : MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag)

Example 5 with MutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.MutableBooleanBag in project eclipse-collections by eclipse.

the class SynchronizedBooleanBagTest method asSynchronized.

@Override
@Test
public void asSynchronized() {
    super.asSynchronized();
    SynchronizedBooleanBag bagWithLockObject = new SynchronizedBooleanBag(BooleanHashBag.newBagWith(true, false, true), new Object());
    Assert.assertSame(bagWithLockObject, bagWithLockObject.asSynchronized());
    Assert.assertEquals(bagWithLockObject, bagWithLockObject.asSynchronized());
    MutableBooleanBag bag = this.classUnderTest();
    Assert.assertSame(bag, bag.asSynchronized());
    Assert.assertEquals(bag, bag.asSynchronized());
}
Also used : MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) Test(org.junit.Test)

Aggregations

MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)19 Test (org.junit.Test)9 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)5 BooleanIterable (org.eclipse.collections.api.BooleanIterable)4 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)4 MutableBag (org.eclipse.collections.api.bag.MutableBag)4 ImmutableBooleanBag (org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag)4 BooleanToObjectFunction (org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction)4 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)4 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)4 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)4 HashBag (org.eclipse.collections.impl.bag.mutable.HashBag)4 AbstractMutableBooleanCollectionTestCase (org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableBooleanCollectionTestCase)4 Lists (org.eclipse.collections.impl.factory.Lists)4 Verify (org.eclipse.collections.impl.test.Verify)4 PrimitiveTuples (org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples)4 Assert (org.junit.Assert)4 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)3 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)2 AbstractBooleanIterable (org.eclipse.collections.impl.primitive.AbstractBooleanIterable)1