Given 2 sets (C++) is there a convenient way to get the size of the intersection without any alocations (as std::set_intersection does)
Sure, I could copy the implementation minus the assignment but I always rather not re-invent the wheel
int count = 0;
while (first1!=last1 && first2!=last2)
{
if (*first1<*first2) ++first1;
else if (*first2<*first1) ++first2;
else {
count++; ++first1; ++first2;
}
}
I was considering using std::set_intersection and pass a "counting" interator...?