Subject: Re: [boost] AlRangeExandrescu?
From: Andrei Alexandrescu (andrei_at_[hidden])
Date: 2009-07-25 10:15:22


Thorsten Ottosen wrote:
> Andrei Alexandrescu skrev:
>> Mathias Gaunard wrote:
>
>>>> You would pass two adjacent ranges, like D's bringToFront (a
>>>> generalization of STL's rotate, see
>>>> http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html) takes.
>>>
>>> Nice idea, that could work.
>>> But how can I generate those two adjacent ranges in the first place
>>> at reasonable costs? Do ranges requires to provide a constant time
>>> "complement" primitive?
>>
>> There's no such need (a range could define it though).
>>
>> A design that has a bidirectional iterator walking freely up and down
>> between two limits would be difficult to port to ranges. (If the
>> iterator is random-access, things are trivial.) Ranges can only
>> shrink, they never grow unless assigned from the outside. So when you
>> move one direction it would be difficult to grow one range (shrinking
>> the other is easy). That design would benefit from letting the
>> iterator abstraction exposed.
>
> Couldn't it be done with a special range that stores three iterators?

Yes, but not within the current primitive set. Sebastian's suggested
interface extension should work.

Andrei