Search in sources :

Example 16 with MutableBooleanSet

use of org.eclipse.collections.api.set.primitive.MutableBooleanSet 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;
}
Also used : BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet)

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