Do sorted ranges have any special properties?

Tomek Sowiński just at ask.me
Tue Jul 27 14:01:12 PDT 2010


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?

> 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...


Tomek


More information about the Digitalmars-d mailing list