mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
vstd: add function to check vector intersection
This commit is contained in:
10
Global.h
10
Global.h
@@ -664,6 +664,16 @@ namespace vstd
|
|||||||
dest.insert(dest.end(), src.begin(), src.end());
|
dest.insert(dest.end(), src.begin(), src.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::vector<T> intersection(std::vector<T> &v1, std::vector<T> &v2)
|
||||||
|
{
|
||||||
|
std::vector<T> v3;
|
||||||
|
std::sort(v1.begin(), v1.end());
|
||||||
|
std::sort(v2.begin(), v2.end());
|
||||||
|
std::set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), back_inserter(v3));
|
||||||
|
return v3;
|
||||||
|
}
|
||||||
|
|
||||||
using boost::math::round;
|
using boost::math::round;
|
||||||
}
|
}
|
||||||
using vstd::operator-=;
|
using vstd::operator-=;
|
||||||
|
Reference in New Issue
Block a user