@Override public String toString() { return makeSparseCopy().toString(); }
@Override public String toString() { return makeSparseCopy().toString(); }
@Override public String toString() { return makeSparseCopy().toString(); }
public IntSet intersection(MutableSharedBitVectorIntSet that) { MutableSparseIntSet t = makeSparseCopy(); t.intersectWith(that); MutableSharedBitVectorIntSet result = new MutableSharedBitVectorIntSet(t); if (PARANOID) { checkIntegrity(); } return result; }
public IntSet intersection(MutableSharedBitVectorIntSet that) { MutableSparseIntSet t = makeSparseCopy(); t.intersectWith(that); MutableSharedBitVectorIntSet result = new MutableSharedBitVectorIntSet(t); if (PARANOID) { checkIntegrity(); } return result; }
public IntSet intersection(MutableSharedBitVectorIntSet that) { MutableSparseIntSet t = makeSparseCopy(); t.intersectWith(that); MutableSharedBitVectorIntSet result = new MutableSharedBitVectorIntSet(t); if (PARANOID) { checkIntegrity(); } return result; }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof BitVectorIntSet) { return that.sameValue(this); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeSparseCopy()); } else { Assertions.UNREACHABLE(that.getClass().toString()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof BitVectorIntSet) { return that.sameValue(this); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeSparseCopy()); } else { Assertions.UNREACHABLE(that.getClass().toString()); return false; } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseIntSet) { return sameValueInternal((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(this); } else if (that instanceof BitVectorIntSet) { return that.sameValue(this); } else if (that instanceof MutableSharedBitVectorIntSet) { return sameValue(((MutableSharedBitVectorIntSet) that).makeSparseCopy()); } else { Assertions.UNREACHABLE(that.getClass().toString()); return false; } }
private boolean sameValue(SparseIntSet that) { if (size() != that.size()) { return false; } if (sharedPart == null) { if (privatePart == null) /* both parts empty, and that has same (i.e. 0) size */ return true; else return privatePart.sameValue(that); } else { /* sharedPart != null */ return makeSparseCopy().sameValue(that); } }
@Override public void copySet(IntSet set) { if (set == null) { throw new IllegalArgumentException("null set"); } if (set instanceof BimodalMutableIntSet) { impl = IntSetUtil.makeMutableCopy(((BimodalMutableIntSet) set).impl); } else if (sameRepresentation(impl, set)) { // V and other.V use the same representation. update in place. impl.copySet(set); } else if (set instanceof BitVectorIntSet || set instanceof SparseIntSet) { // other.V has a different representation. make a new copy impl = IntSetUtil.makeMutableCopy(set); } else if (set instanceof MutableSharedBitVectorIntSet) { impl = IntSetUtil.makeMutableCopy(((MutableSharedBitVectorIntSet) set).makeSparseCopy()); } else { Assertions.UNREACHABLE("Unexpected type " + set.getClass()); } assert impl instanceof BitVectorIntSet || impl instanceof MutableSparseIntSet; }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof MutableSharedBitVectorIntSet) { return sameValue((MutableSharedBitVectorIntSet) that); } else if (that instanceof SparseIntSet) { return sameValue((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(makeSparseCopy()); } else if (that instanceof BitVectorIntSet) { return sameValue((BitVectorIntSet) that); } else if (that instanceof SemiSparseMutableIntSet) { return that.sameValue(this); } else { Assertions.UNREACHABLE("unexpected class " + that.getClass()); return false; } }
private boolean sameValue(SparseIntSet that) { if (size() != that.size()) { return false; } if (sharedPart == null) { if (privatePart == null) /* both parts empty, and that has same (i.e. 0) size */ return true; else return privatePart.sameValue(that); } else { /* sharedPart != null */ return makeSparseCopy().sameValue(that); } }
@Override public void copySet(IntSet set) { if (set == null) { throw new IllegalArgumentException("null set"); } if (set instanceof BimodalMutableIntSet) { impl = IntSetUtil.makeMutableCopy(((BimodalMutableIntSet) set).impl); } else if (sameRepresentation(impl, set)) { // V and other.V use the same representation. update in place. impl.copySet(set); } else if (set instanceof BitVectorIntSet || set instanceof SparseIntSet) { // other.V has a different representation. make a new copy impl = IntSetUtil.makeMutableCopy(set); } else if (set instanceof MutableSharedBitVectorIntSet) { impl = IntSetUtil.makeMutableCopy(((MutableSharedBitVectorIntSet) set).makeSparseCopy()); } else { Assertions.UNREACHABLE("Unexpected type " + set.getClass()); } assert impl instanceof BitVectorIntSet || impl instanceof MutableSparseIntSet; }
private boolean sameValue(SparseIntSet that) { if (size() != that.size()) { return false; } if (sharedPart == null) { if (privatePart == null) /* both parts empty, and that has same (i.e. 0) size */ return true; else return privatePart.sameValue(that); } else { /* sharedPart != null */ return makeSparseCopy().sameValue(that); } }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof MutableSharedBitVectorIntSet) { return sameValue((MutableSharedBitVectorIntSet) that); } else if (that instanceof SparseIntSet) { return sameValue((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(makeSparseCopy()); } else if (that instanceof BitVectorIntSet) { return sameValue((BitVectorIntSet) that); } else if (that instanceof SemiSparseMutableIntSet) { return that.sameValue(this); } else { Assertions.UNREACHABLE("unexpected class " + that.getClass()); return false; } }
@Override public void copySet(IntSet set) { if (set == null) { throw new IllegalArgumentException("null set"); } if (set instanceof BimodalMutableIntSet) { impl = IntSetUtil.makeMutableCopy(((BimodalMutableIntSet) set).impl); } else if (sameRepresentation(impl, set)) { // V and other.V use the same representation. update in place. impl.copySet(set); } else if (set instanceof BitVectorIntSet || set instanceof SparseIntSet) { // other.V has a different representation. make a new copy impl = IntSetUtil.makeMutableCopy(set); } else if (set instanceof MutableSharedBitVectorIntSet) { impl = IntSetUtil.makeMutableCopy(((MutableSharedBitVectorIntSet) set).makeSparseCopy()); } else { Assertions.UNREACHABLE("Unexpected type " + set.getClass()); } assert impl instanceof BitVectorIntSet || impl instanceof MutableSparseIntSet; }
@Override public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError { if (that == null) { throw new IllegalArgumentException("that == null"); } if (that instanceof MutableSharedBitVectorIntSet) { return sameValue((MutableSharedBitVectorIntSet) that); } else if (that instanceof SparseIntSet) { return sameValue((SparseIntSet) that); } else if (that instanceof BimodalMutableIntSet) { return that.sameValue(makeSparseCopy()); } else if (that instanceof BitVectorIntSet) { return sameValue((BitVectorIntSet) that); } else if (that instanceof SemiSparseMutableIntSet) { return that.sameValue(this); } else { Assertions.UNREACHABLE("unexpected class " + that.getClass()); return false; } }
public static BimodalMutableIntSet makeCopy(IntSet B) throws UnimplementedError, IllegalArgumentException { if (B == null) { throw new IllegalArgumentException("B == null"); } if (B instanceof BimodalMutableIntSet) { BimodalMutableIntSet that = (BimodalMutableIntSet) B; BimodalMutableIntSet result = new BimodalMutableIntSet(); result.impl = IntSetUtil.makeMutableCopy(that.impl); return result; } else if (B instanceof MutableSharedBitVectorIntSet) { BimodalMutableIntSet result = new BimodalMutableIntSet(); MutableSharedBitVectorIntSet s = (MutableSharedBitVectorIntSet) B; result.impl = IntSetUtil.makeMutableCopy(s.makeSparseCopy()); assert result.impl instanceof BitVectorIntSet || result.impl instanceof MutableSparseIntSet; return result; } else { BimodalMutableIntSet result = new BimodalMutableIntSet(); result.impl = IntSetUtil.makeMutableCopy(B); assert result.impl instanceof BitVectorIntSet || result.impl instanceof MutableSparseIntSet; return result; } }
@Override public boolean remove(int i) { if (privatePart != null) { if (privatePart.contains(i)) { privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } return true; } } if (sharedPart != null) { if (sharedPart.contains(i)) { privatePart = makeSparseCopy(); privatePart.remove(i); if (privatePart.size() == 0) { privatePart = null; } sharedPart = null; checkOverflow(); return true; } } return false; }