/** * this method computes the intersection between this set and ot set. * * @param ot - the other set */ public VertexSet intersection(VertexSet ot) { VertexSet ans = new VertexSet(); int i1 = 0, i2 = 0; while (i1 < this.size() & i2 < ot.size()) { int a1 = this.at(i1), a2 = ot.at(i2); if (a1 == a2) { ans.add(a1); i1++; i2++; } else if (a1 < a2) { i1++; } else i2++; } return ans; }
public VertexSet(VertexSet ot) { _set = new int[INIT_SIZE]; _sp = 0; for (int i = 0; i < ot.size(); i++) this.add(ot.at(i)); }