]> git.lyx.org Git - lyx.git/blobdiff - src/support/lyxalgo.h
* lyxfunctional.h: delete compare_memfun and helper classes
[lyx.git] / src / support / lyxalgo.h
index 87848bb1a5d702fd86853d485765d0026ce62b13..19ed2e857d1846102cc70457b18ca49725a3cf35 100644 (file)
@@ -17,7 +17,6 @@
 #include <utility>
 #include <iterator>
 #include <algorithm>
-#include <set>
 
 
 namespace lyx {
@@ -93,16 +92,10 @@ count (Iterator first, Iterator last, T const & value)
 template<class C>
 void eliminate_duplicates(C & c)
 {
-       C unique_c;
-       std::set<typename C::value_type> s;
-
-       for (typename C::iterator p = c.begin(); p != c.end(); ++p) {
-               if (s.find(*p) == s.end()) {
-                       unique_c.push_back(*p);
-                       s.insert(*p);
-               }
-       }
-       swap(c, unique_c);
+       // It is a requirement that the container is sorted for
+       // std::unique to work properly.
+       std::sort(c.begin(), c.end());
+       c.erase(std::unique(c.begin(), c.end()), c.end());
 }
 
 } // namespace lyx