ObjectType Module::specifyLocally(const ObjectType& parent) const { ObjectType type; ObjectType rangeBegin(parent.typeTemplate()); for(SpecificationMap::const_iterator it = _automaticSpecifications.lower_bound(&rangeBegin); it != _automaticSpecifications.end() && it->first->typeTemplate() == parent.typeTemplate(); ++it) { if(parent.extendsDirectly(*(it->first))) { type = it->second; type.importParameters(parent); break; } } return type; }
bool Set::intersection(const Set* set, Set** intersection, Set** complement) const { if (complement) { (*complement) = new Set(); } if (!set) { if (intersection) { (*intersection) = new Set(*this); } return true; } if (intersection) { (*intersection) = new Set(); } bool hasIntersection = false; Set::range_iterator filterIt = set->rangeBegin(); Set::range_iterator setIt = rangeBegin(); Set::range_iterator setEnd = rangeEnd(); Set::range_iterator filterEnd = set->rangeEnd(); for (; setIt != setEnd; ++setIt) { IdentifierType setLow = setIt.low(); IdentifierType setHigh = setIt.high(); if (filterIt == filterEnd) { if (!intersection && !complement) { return false; } if (complement) { (*complement)->insertRange(setLow, setHigh); } else { break; } } else { IdentifierType setCurr = setLow; while (filterIt != filterEnd) { IdentifierType filterLow = filterIt.low(); IdentifierType filterHigh = filterIt.high(); if (filterHigh < setLow) { ++filterIt; } else if (filterLow > setHigh) { break; } else { hasIntersection = true; if (!intersection && !complement) { return true; } if (complement && setCurr < filterLow) { (*complement)->insertRange(setCurr, filterLow - 1); } setCurr = min(setHigh, filterHigh); if (intersection) { (*intersection)->insertRange(max(filterLow, setLow), setCurr); } ++setCurr; if (filterHigh > setHigh) { break; } else { ++filterIt; } } } if (complement && setCurr <= setHigh) { (*complement)->insertRange(setCurr, setHigh); } } } return hasIntersection; }