From e4f591ba845cb8ca5d59e629b973b11ff8f9a800 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Sun, 8 Mar 2015 14:41:17 +0300 Subject: [PATCH] vstd: add function to check vector intersection --- Global.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Global.h b/Global.h index 14b9ffd56..e3622a12e 100644 --- a/Global.h +++ b/Global.h @@ -664,6 +664,16 @@ namespace vstd dest.insert(dest.end(), src.begin(), src.end()); } + template + std::vector intersection(std::vector &v1, std::vector &v2) + { + std::vector 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 vstd::operator-=;