On Tue, Mar 28, 2006 at 09:13:41PM +0200, Abdelrazak Younes wrote: > Martin Vermeer a écrit : > >On Tue, Mar 28, 2006 at 08:30:29PM +0200, Abdelrazak Younes wrote: > > > >>Martin Vermeer a écrit :
... > >How? I don't quite see it. > > > Here is a modified version of your code (not tested and won't work > because of missing method in RandomAccessList). It could be simplified > even more thanks to direct access. > > void Outline(OutlineOp mode, Buffer * buf, pit_type & pit) > { > ParagraphList & pars = buf->text().paragraphs(); > pit_type bgn = 0; > pit_type s = pit; > pit_type p = pit; > pit_type end = pars.size(); Ah! No iterators at all. ... > pit_type const newpit = q; //std::distance(pars.begin(), q); > pit_type const len = p - s; //std::distance(s, p); > pit += len; > // Lars has deleted all my convenience methods in RandomAccessList So there's the crunch. > // especially one that offered this one: > pars.insert(q, s, p); Or: pars.insert(boost::next(pars.begin(), q), boost::next(pars.begin(), s, boost::next(pars.begin(), p); > s = pit; > pit_type t = s + len; > // and also this one: > pars.erase(s, t); And there... pars.erase(boost::next(pars.begin(), s), boost::next(pars.begin(), t); > pit = newpit; > break; > } Not very pretty... I see why you had your helper methods. I suppose I'll just commit as is (it's not speed critical), perhaps with FIXME's. This can always be modified later. - Martin
pgp5bYwY9ZrDl.pgp
Description: PGP signature