X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FRandomAccessList.h;h=2565d62513158ecc57e0f306ef471c9b477ab264;hb=8d640dc77608bedddb5b00982c23665584f52d21;hp=22c0572e192a82443259cd334cf77c6efc6dbe81;hpb=6c300f72a217722652dc27db9108e1050028979c;p=lyx.git diff --git a/src/support/RandomAccessList.h b/src/support/RandomAccessList.h index 22c0572e19..2565d62513 100644 --- a/src/support/RandomAccessList.h +++ b/src/support/RandomAccessList.h @@ -13,13 +13,8 @@ #ifndef RANDOM_ACESS_LIST_H #define RANDOM_ACESS_LIST_H -//#include "debug.h" - -#include - #include #include -#include namespace lyx { @@ -251,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_); @@ -263,6 +273,32 @@ public: iterCont_.clear(); } + size_t position(iterator it) const + { + size_t const s = iterCont_.size(); + for (size_t i = 0; it != s; ++i) { + if (iterCont_[i] == it) + return i; + } + return s; + } + + size_t position(const_iterator it) const + { + size_t const s = iterCont_.size(); + for (size_t i = 0; i != s; ++i) { + if (iterCont_[i] == it) + return i; + } + return s; + } + + + const_iterator constIterator(size_t i) const + { + return iterCont_[i]; + } + private: void recreateVector() {