Search in sources :

Example 1 with BooleanHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project eclipse-collections by eclipse.

the class ImmutableBooleanSetSerializationProxy method readExternal.

@Override
public void readExternal(ObjectInput in) throws IOException {
    int size = in.readInt();
    MutableBooleanSet deserializedSet = new BooleanHashSet();
    for (int i = 0; i < size; i++) {
        deserializedSet.add(in.readBoolean());
    }
    this.set = deserializedSet;
}
Also used : BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet)

Example 2 with BooleanHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project eclipse-collections by eclipse.

the class BooleanSetsTest method newSetWithSet.

@Test
public void newSetWithSet() {
    ImmutableBooleanSet set = BooleanSets.immutable.with();
    BooleanHashSet booleanHashSet = BooleanHashSet.newSetWith(true);
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.toImmutable());
    Assert.assertEquals(set = set.newWith(false), booleanHashSet.with(false).toImmutable());
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.with(true).toImmutable());
    Assert.assertEquals(set = set.newWith(false), booleanHashSet.with(false).toImmutable());
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.with(true).toImmutable());
    Assert.assertEquals(set = set.newWith(false), booleanHashSet.with(false).toImmutable());
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.with(true).toImmutable());
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.with(true).toImmutable());
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.with(true).toImmutable());
    Assert.assertEquals(set = set.newWith(false), booleanHashSet.with(false).toImmutable());
    Assert.assertEquals(set = set.newWith(true), booleanHashSet.with(true).toImmutable());
}
Also used : ImmutableBooleanSet(org.eclipse.collections.api.set.primitive.ImmutableBooleanSet) BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) Test(org.junit.Test)

Example 3 with BooleanHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project eclipse-collections by eclipse.

the class ImmutableBooleanArrayList method distinct.

/**
 * @since 6.0
 */
@Override
public ImmutableBooleanList distinct() {
    BooleanArrayList target = new BooleanArrayList();
    MutableBooleanSet seenSoFar = new BooleanHashSet();
    for (int i = 0; i < this.size; i++) {
        boolean each = this.get(i);
        if (seenSoFar.add(each)) {
            target.add(each);
        }
    }
    return target.toImmutable();
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet)

Example 4 with BooleanHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project eclipse-collections by eclipse.

the class StackIterableTestCase method collectBooleanWithTarget.

@Override
@Test
public void collectBooleanWithTarget() {
    BooleanHashSet target = new BooleanHashSet();
    StackIterable<String> stack = this.newStackFromTopToBottom("true", "nah", "TrUe", "false");
    BooleanHashSet result = stack.collectBoolean(Boolean::parseBoolean, target);
    Assert.assertEquals(BooleanHashSet.newSetWith(true, false, true, false), result);
    Assert.assertSame("Target sent as parameter not returned", target, result);
}
Also used : BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) Test(org.junit.Test)

Example 5 with BooleanHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project narchy by automenta.

the class BooleanArrayList method removeAll.

public boolean removeAll(boolean... source) {
    if (isEmpty() || source.length == 0) {
        return false;
    }
    BooleanHashSet set = BooleanHashSet.newSetWith(source);
    if (set.size() == 2) {
        size = 0;
        return true;
    }
    int oldSize = size;
    int trueCount = getTrueCount();
    if (set.contains(true)) {
        size -= trueCount;
        set(0, size, false);
    } else {
        size = trueCount;
        set(0, size, true);
    }
    return oldSize != size;
}
Also used : BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)

Aggregations

BooleanHashSet (org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)12 MutableBooleanSet (org.eclipse.collections.api.set.primitive.MutableBooleanSet)5 Test (org.junit.Test)4 ImmutableBooleanSetFactory (org.eclipse.collections.api.factory.set.primitive.ImmutableBooleanSetFactory)1 ImmutableBooleanSet (org.eclipse.collections.api.set.primitive.ImmutableBooleanSet)1 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)1