diff options
Diffstat (limited to 'zen/stl_tools.h')
-rw-r--r-- | zen/stl_tools.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/zen/stl_tools.h b/zen/stl_tools.h index bd76e264..685f5118 100644 --- a/zen/stl_tools.h +++ b/zen/stl_tools.h @@ -9,7 +9,7 @@ #include <memory> #include <algorithm> -#include <zen/type_tools.h> +#include "type_tools.h" //enhancements for <algorithm> @@ -22,6 +22,9 @@ void vector_remove_if(V& vec, Predicate p); template <class V, class W> void vector_append(V& vec, const W& vec2); +template <class V> +void removeDuplicates(V& v); + template <class V, class W> void set_append(V& s, const W& s2); @@ -72,6 +75,14 @@ void vector_remove_if(V& vec, Predicate p) } +template <class V> inline +void removeDuplicates(V& v) +{ + std::sort(v.begin(), v.end()); + v.erase(std::unique(v.begin(), v.end()), v.end()); +} + + template <class V, class W> inline void vector_append(V& vec, const W& vec2) { |