void NormalizedConstraintSet::StringRange::Intersect(const StringRange& aOther) { if (!aOther.mExact.size()) { return; } ValueType intersection; set_intersection(mExact.begin(), mExact.end(), aOther.mExact.begin(), aOther.mExact.end(), std::inserter(intersection, intersection.begin())); mExact = intersection; }
bool NormalizedConstraintSet::StringRange::Intersects(const StringRange& aOther) const { if (!mExact.size() || !aOther.mExact.size()) { return true; } ValueType intersection; set_intersection(mExact.begin(), mExact.end(), aOther.mExact.begin(), aOther.mExact.end(), std::inserter(intersection, intersection.begin())); return !!intersection.size(); }
bool NormalizedConstraintSet::StringRange::Merge(const StringRange& aOther) { if (!Intersects(aOther)) { return false; } Intersect(aOther); ValueType unioned; set_union(mIdeal.begin(), mIdeal.end(), aOther.mIdeal.begin(), aOther.mIdeal.end(), std::inserter(unioned, unioned.begin())); mIdeal = unioned; return true; }