Search in sources :

Example 1 with MutableBooleanSet

use of org.eclipse.collections.api.set.primitive.MutableBooleanSet 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 MutableBooleanSet

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

use of org.eclipse.collections.api.set.primitive.MutableBooleanSet in project eclipse-collections by eclipse.

the class AbstractBooleanSetTestCase method retainAll_iterable.

@Override
@Test
public void retainAll_iterable() {
    super.retainAll_iterable();
    Assert.assertFalse(this.emptySet.retainAll(new BooleanArrayList()));
    Assert.assertTrue(this.setWithTrueFalse.retainAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertEquals(BooleanHashSet.newSetWith(true), this.setWithTrueFalse);
    MutableBooleanSet set = this.newWith(true, false);
    Assert.assertTrue(set.retainAll(BooleanArrayList.newListWith()));
    Assert.assertEquals(BooleanHashSet.newSetWith(), set);
    MutableBooleanSet sett = this.newWith(true, false);
    Assert.assertTrue(sett.retainAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertEquals(BooleanHashSet.newSetWith(false), sett);
    MutableBooleanSet sett2 = this.newWith(true);
    Assert.assertTrue(sett2.retainAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertEquals(BooleanHashSet.newSetWith(), sett2);
    Assert.assertTrue(this.setWithTrue.retainAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertFalse(this.setWithTrue.retainAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertEquals(BooleanHashSet.newSetWith(), this.setWithTrue);
    MutableBooleanSet sett3 = this.newWith(false);
    Assert.assertFalse(sett3.retainAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertEquals(BooleanHashSet.newSetWith(false), sett3);
    Assert.assertTrue(this.setWithFalse.retainAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertFalse(this.setWithFalse.retainAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertEquals(BooleanHashSet.newSetWith(), this.setWithFalse);
    Assert.assertFalse(this.emptySet.retainAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertFalse(this.emptySet.retainAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertFalse(this.emptySet.retainAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertEquals(BooleanHashSet.newSetWith(), this.emptySet);
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet) Test(org.junit.Test)

Example 4 with MutableBooleanSet

use of org.eclipse.collections.api.set.primitive.MutableBooleanSet in project eclipse-collections by eclipse.

the class AbstractBooleanSetTestCase method withAll.

@Override
@Test
public void withAll() {
    super.withAll();
    MutableBooleanCollection emptySet = this.newWith();
    MutableBooleanCollection set = emptySet.withAll(BooleanArrayList.newListWith(false));
    MutableBooleanSet set1 = this.newWith().withAll(BooleanArrayList.newListWith(true));
    MutableBooleanSet set2 = this.newWith().withAll(BooleanArrayList.newListWith(true, false));
    MutableBooleanSet set3 = this.newWith().withAll(BooleanArrayList.newListWith(true, false));
    Assert.assertSame(emptySet, set);
    Assert.assertEquals(this.setWithFalse, set);
    Assert.assertEquals(this.setWithTrue, set1);
    Assert.assertEquals(this.setWithTrueFalse, set2);
    Assert.assertEquals(this.setWithTrueFalse, set3);
    Assert.assertEquals(BooleanHashSet.newSetWith(true, false), this.setWithTrueFalse.withAll(BooleanHashSet.newSetWith(true, false)));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet) Test(org.junit.Test)

Example 5 with MutableBooleanSet

use of org.eclipse.collections.api.set.primitive.MutableBooleanSet in project eclipse-collections by eclipse.

the class AbstractBooleanSetTestCase method removeAll.

@Override
@Test
public void removeAll() {
    super.removeAll();
    Assert.assertFalse(this.emptySet.removeAll());
    Assert.assertFalse(this.setWithFalse.removeAll());
    Assert.assertFalse(this.setWithTrue.removeAll());
    Assert.assertFalse(this.setWithTrueFalse.removeAll());
    Assert.assertTrue(this.setWithTrueFalse.removeAll(true, true));
    Assert.assertEquals(BooleanHashSet.newSetWith(false), this.setWithTrueFalse);
    MutableBooleanSet set = this.newWith(true, false);
    Assert.assertTrue(set.removeAll(true, false));
    Assert.assertEquals(BooleanHashSet.newSetWith(), set);
    MutableBooleanSet sett = this.newWith(true, false);
    Assert.assertTrue(sett.removeAll(false, false));
    Assert.assertEquals(BooleanHashSet.newSetWith(true), sett);
    Assert.assertFalse(this.setWithTrue.removeAll(false, false));
    MutableBooleanSet sett2 = this.newWith(true);
    Assert.assertTrue(sett2.removeAll(true, true));
    Assert.assertEquals(BooleanHashSet.newSetWith(), sett2);
    Assert.assertTrue(this.setWithTrue.removeAll(true, false));
    Assert.assertEquals(BooleanHashSet.newSetWith(), this.setWithTrue);
    Assert.assertFalse(this.setWithFalse.removeAll(true, true));
    MutableBooleanSet sett3 = this.newWith(false);
    Assert.assertTrue(sett3.removeAll(false, false));
    Assert.assertEquals(BooleanHashSet.newSetWith(), sett3);
    Assert.assertTrue(this.setWithFalse.removeAll(true, false));
    Assert.assertEquals(BooleanHashSet.newSetWith(), this.setWithFalse);
    Assert.assertFalse(this.emptySet.removeAll(true, true));
    Assert.assertFalse(this.emptySet.removeAll(true, false));
    Assert.assertFalse(this.emptySet.removeAll(false, false));
    Assert.assertEquals(BooleanHashSet.newSetWith(), this.emptySet);
}
Also used : MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet) Test(org.junit.Test)

Aggregations

MutableBooleanSet (org.eclipse.collections.api.set.primitive.MutableBooleanSet)16 Test (org.junit.Test)11 BooleanHashSet (org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)5 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)3 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)2