GIDSet CompartmentReportCommon::_computeIntersection(const GIDSet& all, const GIDSet& subset) { GIDSet intersection; std::set_intersection(subset.begin(), subset.end(), all.begin(), all.end(), std::inserter(intersection, intersection.begin())); if (intersection != subset || intersection.empty()) { LBWARN << "Requested " << subset.size() << " GIDs [" << *subset.begin() << ":" << *subset.rbegin() << "] are not a subset of the " << all.size() << " GIDs in the report [" << *all.begin() << ":" << *all.rbegin(); if (intersection.empty()) LBWARN << " with no GIDs in common" << std::endl; else LBWARN << "], using intersection size " << intersection.size() << " [" << *intersection.begin() << ":" << *intersection.rbegin() << "]" << std::endl; } return intersection; }
std::vector<uint32_t> CompartmentReportCommon::_computeSubsetIndices( const GIDSet& source, const GIDSet& target) { GIDSet::iterator i = source.begin(); std::vector<uint32_t> indices; indices.reserve(target.size()); uint32_t sourceIndex = 0; for (const auto gid : target) { assert(i != source.end()); while (*i != gid) { ++i; ++sourceIndex; } indices.push_back(sourceIndex); } return indices; }