/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } SemiSparseMutableIntSet newThis = new SemiSparseMutableIntSet(); for (IntIterator bits = intIterator(); bits.hasNext();) { int bit = bits.next(); if (that.contains(bit)) { newThis.add(bit); } } return newThis; }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } SemiSparseMutableIntSet newThis = new SemiSparseMutableIntSet(); for (IntIterator bits = intIterator(); bits.hasNext();) { int bit = bits.next(); if (that.contains(bit)) { newThis.add(bit); } } return newThis; }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } SemiSparseMutableIntSet newThis = new SemiSparseMutableIntSet(); for (IntIterator bits = intIterator(); bits.hasNext();) { int bit = bits.next(); if (that.contains(bit)) { newThis.add(bit); } } return newThis; }