private void slowForeachExcluding(IntSet X, IntSetAction action) { populationCount = (populationCount == UNDEFINED) ? bitVector.populationCount() : populationCount; for (int i = 0, count = 0; count < populationCount; i++) { if (contains(i)) { if (!X.contains(i)) { action.act(i); } count++; } } }
private static IntSet getDomain(IBinaryNaturalRelation r) { MutableIntSet result = MutableSparseIntSet.makeEmpty(); int maxKeyValue = r.maxKeyValue(); for (int i = 0; i <= maxKeyValue; i++) { if (r.getRelated(i) != null) { result.add(i); } } return result; }
/** * Set a particular bit * * @param b the bit to set */ public boolean add(int b) { if (V == null) { V = IntSetUtil.getDefaultIntSetFactory().make(); } return V.add(b); }
/** * TODO: optimize * */ public SparseIntSet toSparseIntSet() { MutableSparseIntSet result = MutableSparseIntSet.makeEmpty(); for (IntIterator it = intIterator(); it.hasNext();) { result.add(it.next()); } return result; }
private OrdinalSet<InstanceKey> toOrdinalSet(InstanceKey[] ik) { MutableSparseIntSet s = MutableSparseIntSet.makeEmpty(); for (InstanceKey element : ik) { int index = instanceKeys.getMappedIndex(element); if (index != -1) { s.add(index); } else { assert index != -1 : "instance " + element + " not mapped!"; } } return new OrdinalSet<>(s, instanceKeys); }
@Override public boolean addAll(IntSet set) { if (set instanceof BitVectorIntSet && !(impl instanceof BitVectorIntSet)) { // change the representation before performing the operation impl = new BitVectorIntSet(impl); } boolean result = impl.addAll(set); if (result) { maybeChangeRepresentation(); } return result; }
/** * */ private void checkIntegrity() { assert privatePart == null || !privatePart.isEmpty(); assert sharedPart == null || !sharedPart.isEmpty(); if (privatePart != null && sharedPart != null) { assert privatePart.intersection(sharedPart).isEmpty(); } }
@Override public boolean addAllInIntersection(IntSet other, IntSet filter) { if (other instanceof BitVectorIntSet && !(impl instanceof BitVectorIntSet)) { // change the representation before performing the operation impl = new BitVectorIntSet(impl); } boolean result = impl.addAllInIntersection(other, filter); if (result) { maybeChangeRepresentation(); } return result; }
/** * @return true iff this set contains integer i */ @Override public boolean contains(int i) { if (densePart != null && inDenseRange(i)) { return densePart.contains(i); } else { return sparsePart.contains(i); } }
/** * TODO: optimize * */ public SparseIntSet toSparseIntSet() { MutableSparseIntSet result = MutableSparseIntSet.makeEmpty(); for (IntIterator it = intIterator(); it.hasNext();) { result.add(it.next()); } return result; }
/** * Set a particular bit * * @param b the bit to set */ public boolean add(int b) { if (V == null) { V = IntSetUtil.getDefaultIntSetFactory().make(); } return V.add(b); }
private void slowForeachExcluding(IntSet X, IntSetAction action) { populationCount = (populationCount == UNDEFINED) ? bitVector.populationCount() : populationCount; for (int i = 0, count = 0; count < populationCount; i++) { if (contains(i)) { if (!X.contains(i)) { action.act(i); } count++; } } }
@Override public boolean addAll(IntSet set) { if (set instanceof BitVectorIntSet && !(impl instanceof BitVectorIntSet)) { // change the representation before performing the operation impl = new BitVectorIntSet(impl); } boolean result = impl.addAll(set); if (result) { maybeChangeRepresentation(); } return result; }
/** * */ private void checkIntegrity() { assert privatePart == null || !privatePart.isEmpty(); assert sharedPart == null || !sharedPart.isEmpty(); if (privatePart != null && sharedPart != null) { assert privatePart.intersection(sharedPart).isEmpty(); } }
@Override public boolean addAllInIntersection(IntSet other, IntSet filter) { if (other instanceof BitVectorIntSet && !(impl instanceof BitVectorIntSet)) { // change the representation before performing the operation impl = new BitVectorIntSet(impl); } boolean result = impl.addAllInIntersection(other, filter); if (result) { maybeChangeRepresentation(); } return result; }
/** * @return true iff this set contains integer i */ @Override public boolean contains(int i) { if (densePart != null && inDenseRange(i)) { return densePart.contains(i); } else { return sparsePart.contains(i); } }
/** * TODO: optimize * */ public SparseIntSet toSparseIntSet() { MutableSparseIntSet result = MutableSparseIntSet.makeEmpty(); for (IntIterator it = intIterator(); it.hasNext();) { result.add(it.next()); } return result; }
/** * Set a particular bit * * @param b the bit to set */ public boolean add(int b) { if (V == null) { V = IntSetUtil.getDefaultIntSetFactory().make(); } return V.add(b); }
private void slowForeachExcluding(IntSet X, IntSetAction action) { populationCount = (populationCount == UNDEFINED) ? bitVector.populationCount() : populationCount; for (int i = 0, count = 0; count < populationCount; i++) { if (contains(i)) { if (!X.contains(i)) { action.act(i); } count++; } } }
/** * @return true iff this set contains integer i */ @Override public boolean contains(int i) { if (densePart != null && inDenseRange(i)) { return densePart.contains(i); } else { return sparsePart.contains(i); } }