mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
RandomAccessList: new swap() method for swapping two elements without any copy.
LFUN_PARAGRAPH_MOVE_UP and LFUN_PARAGRAPH_MOVE_DOWN: use that. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30958 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8c053ea10c
commit
1a27aaca77
@ -554,7 +554,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
pit_type const pit = cur.pit();
|
||||
recUndo(cur, pit, pit + 1);
|
||||
cur.finishUndo();
|
||||
swap(pars_[pit], pars_[pit + 1]);
|
||||
pars_.swap(pit, pit + 1);
|
||||
cur.buffer()->updateLabels();
|
||||
needsUpdate = true;
|
||||
++cur.pit();
|
||||
@ -565,7 +565,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
pit_type const pit = cur.pit();
|
||||
recUndo(cur, pit - 1, pit);
|
||||
cur.finishUndo();
|
||||
swap(pars_[pit], pars_[pit - 1]);
|
||||
pars_.swap(pit, pit - 1);
|
||||
cur.buffer()->updateLabels();
|
||||
--cur.pit();
|
||||
needsUpdate = true;
|
||||
|
@ -246,6 +246,15 @@ public:
|
||||
return it;
|
||||
}
|
||||
|
||||
void swap(size_t i, size_t j)
|
||||
{
|
||||
size_t const p = max(i, j);
|
||||
size_t const q = min(i, j);
|
||||
container_.splice(iterCont_[p], container_, iterCont_[q]);
|
||||
container_.splice(iterCont_[q], container_, iterCont_[p]);
|
||||
recreateVector();
|
||||
}
|
||||
|
||||
void swap(RandomAccessList & x)
|
||||
{
|
||||
std::swap(container_, x.container_);
|
||||
|
Loading…
Reference in New Issue
Block a user