@Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } if (that instanceof MutableSharedBitVectorIntSet) { return intersection((MutableSharedBitVectorIntSet) that); } else if (that instanceof BitVectorIntSet) { MutableSharedBitVectorIntSet m = new MutableSharedBitVectorIntSet((BitVectorIntSet) that); return intersection(m); } else if (that instanceof SparseIntSet) { BitVectorIntSet bv = new BitVectorIntSet(that); return intersection(bv); } else { // really slow. optimize as needed. BitVectorIntSet result = new BitVectorIntSet(); for (IntIterator it = intIterator(); it.hasNext();) { int x = it.next(); if (that.contains(x)) { result.add(x); } } return result; } }
@Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } if (that instanceof MutableSharedBitVectorIntSet) { return intersection((MutableSharedBitVectorIntSet) that); } else if (that instanceof BitVectorIntSet) { MutableSharedBitVectorIntSet m = new MutableSharedBitVectorIntSet((BitVectorIntSet) that); return intersection(m); } else if (that instanceof SparseIntSet) { BitVectorIntSet bv = new BitVectorIntSet(that); return intersection(bv); } else { // really slow. optimize as needed. BitVectorIntSet result = new BitVectorIntSet(); for (IntIterator it = intIterator(); it.hasNext();) { int x = it.next(); if (that.contains(x)) { result.add(x); } } return result; } }
@Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } if (that instanceof MutableSharedBitVectorIntSet) { return intersection((MutableSharedBitVectorIntSet) that); } else if (that instanceof BitVectorIntSet) { MutableSharedBitVectorIntSet m = new MutableSharedBitVectorIntSet((BitVectorIntSet) that); return intersection(m); } else if (that instanceof SparseIntSet) { BitVectorIntSet bv = new BitVectorIntSet(that); return intersection(bv); } else { // really slow. optimize as needed. BitVectorIntSet result = new BitVectorIntSet(); for (IntIterator it = intIterator(); it.hasNext();) { int x = it.next(); if (that.contains(x)) { result.add(x); } } return result; } }