use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project eclipse-collections by eclipse.
the class BooleanArrayList method distinct.
/**
* @since 6.0
*/
@Override
public MutableBooleanList 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;
}
use of org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet in project eclipse-collections by eclipse.
the class BooleanArrayList method removeAll.
@Override
public boolean removeAll(boolean... source) {
if (this.isEmpty() || source.length == 0) {
return false;
}
BooleanHashSet set = BooleanHashSet.newSetWith(source);
if (set.size() == 2) {
this.items = null;
this.size = 0;
return true;
}
int oldSize = this.size;
int trueCount = this.getTrueCount();
if (set.contains(true)) {
this.size -= trueCount;
this.items.set(0, this.size, false);
} else {
this.size = trueCount;
this.items.set(0, this.size, true);
}
return oldSize != this.size;
}
Aggregations