Files
comaps/base/set_operations.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

32 lines
924 B
C++

#pragma once
// Similar to set_difference(), but if element is present n times in the first sequence and once in
// the second sequence, all n copies are filtered, insted of one.
template<typename Iter1T, typename Iter2T, typename OutIterT, typename LessT>
OutIterT SetDifferenceUnlimited(Iter1T beg1, Iter1T end1,
Iter2T beg2, Iter2T end2,
OutIterT out, LessT lessCompare)
{
while (beg1 != end1 && beg2 != end2)
{
if (lessCompare(*beg1, *beg2))
{
*out = *beg1;
++beg1;
++out;
}
else if (lessCompare(*beg2, *beg1))
{
++beg2;
}
else
{
++beg1;
// This is the difference between set_difference and this function:
// In set_difference the commented line should be present.
// ++beg2;
}
}
return std::copy(beg1, end1, out);
}