]> git.lyx.org Git - lyx.git/blobdiff - src/support/RandomAccessList.h
CMake: fix merged build, seems GCC could not handle the namespaces correctly
[lyx.git] / src / support / RandomAccessList.h
index 2e419bd7001491cdf87cf52fdd3069dc1a6d3200..7b0f1032ddf62af4d2c4366b3889071b8a0ad4a7 100644 (file)
 #ifndef RANDOM_ACESS_LIST_H
 #define RANDOM_ACESS_LIST_H
 
-//#include "debug.h"
-
-#include <boost/utility.hpp>
-
 #include <vector>
 #include <list>
-#include <algorithm>
+
+
+namespace lyx {
 
 #define USE_OLD_ITERATOR 1
 
@@ -31,7 +29,7 @@ keeps the std::list::iterator interface. A typical use would be:
 
        typedef RandomAccessList<some_class> MyContainer;
 
-Then you can use MyContainer as if it was a standard 
+Then you can use MyContainer as if it was a standard
 std::vector<some_class> for operator[] access and as if it was a
 standard std::list for iterator access. The main difference with
 std::vector is that insertion of elements is much less costly. Compared
@@ -248,6 +246,21 @@ public:
                return it;
        }
 
+       void swap(size_t i, size_t j)
+       {
+               size_t const p = std::max(i, j);
+               size_t const q = std::min(i, j);
+               container_.splice(iterCont_[p], container_, iterCont_[q]);
+               container_.splice(iterCont_[q], container_, iterCont_[p]);
+               recreateVector();
+       }
+
+       void splice(iterator where, iterator first, iterator last)
+       {
+               container_.splice(where, container_, first, last);
+               recreateVector();
+       }
+
        void swap(RandomAccessList & x)
        {
                std::swap(container_, x.container_);
@@ -276,4 +289,7 @@ private:
        IterCont iterCont_;
 };
 
+
+} // namespace lyx
+
 #endif