Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'base/stl_helpers.hpp')
-rw-r--r--base/stl_helpers.hpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/base/stl_helpers.hpp b/base/stl_helpers.hpp
index 035b77e161..b11f95eec7 100644
--- a/base/stl_helpers.hpp
+++ b/base/stl_helpers.hpp
@@ -86,20 +86,13 @@ void SortUnique(vector<T> & v)
v.erase(unique(v.begin(), v.end()), v.end());
}
-// Sorts and removes duplicate entries from |v| according to |comp|.
-// Note. If several entries are equivalent according to |comp| an arbitrary entry of them
-// is left in |v| after a call of this method.
-// Note. |comp| should implement operator<. It means the expression
-// !comp(t1, t2) && !comp(t2, t1) should return true iff t1 is equivalent to t2.
-// It's necessary for std::unique.
-template <typename T>
-void SortUnique(function<bool(T const &, T const &)> const & comp, vector<T> & v)
+// Sorts according to |comp| and removes duplicate entries according to |pred| from |v|.
+// Note. If several entries are equal according to |pred| an arbitrary entry of them
+// is left in |v| after a call of this function.
+template <typename T, typename TComp, typename TPred>
+void SortUnique(vector<T> & v, TComp && comp, TPred && pred)
{
sort(v.begin(), v.end(), comp);
- function<bool(T const &, T const &)> const pred = [&comp](T const & t1, T const & t2)
- {
- return !comp(t1, t2) && !comp(t2, t1);
- };
v.erase(unique(v.begin(), v.end(), pred), v.end());
}