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;
}
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());
}
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();
}
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);
}
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;
}
Aggregations