Do sorted ranges have any special properties?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 27 15:18:38 PDT 2010
Tomek Sowiński wrote:
> Andrei Alexandrescu wrote:
>
>> - All binary search operators (lowerBound, upperBound, equalRange)
>> should be made members of Sorted!Range. So instead of writing:
>>
>> // We know r is sorted, baby
>> auto r1 = upperBound(r, x);
>>
>> you'd write:
>>
>> auto r1 = assumeSorted(r).upperBound(x);
>
> Some of std.algorithm (e.g. find, partition) can profit on sortedness, others
> (e.g. group, setIntersection, setDifference, nWayUnion) require it. Do you
> want to put *all* of them as members of Sorted?
Affirmative.
>> This all raises the question: where should this Sorted(R) in the making
>> go? It's a range so it should go in std.range, but it's mostly a
>> motivator for algorithms, so it should go in std.algorithm. Tiebreakers?
>
> If members are algorithms then in algorithm...
Yah but the type is a range.
Andrei
More information about the Digitalmars-d
mailing list