On 8/27/10 16:38 PDT, Manfred_Nowak wrote:
Andrei Alexandrescu wrote:

retro is O(1) today.

Thx, but then I am missing the whole point of this thread.

It's simple: the OP wanted this:

- start with a bidir range r

- move from the LEFT in it for a while

- then reverse whatever is to the LEFT of the walking point

This is impossible in today's D without extra walks. You can reverse what's to the RIGHT of the walking point. You can also reverse what's to the LEFT of the walking point IF you start the walk from the right.

The more I think of it, the more I think beforeAll(r, postfix) and afterAll(r, prefix) are two optional primitives that should cover this need very nicely and safely. In my previous unslept nights when I was tormented by this I couldn't see that these primitives are actually provably save in O(1) time.


Andrei

Reply via email to