How to override opCmp when two different sorts are needed?
Regan Heath
regan at netmail.co.nz
Wed Aug 15 01:24:36 PDT 2007
C. Dunn wrote:
> Jarrett Billingsley Wrote:
>> Write your own sort routine which takes a given predicate. :\
>>
>> Tango provides such a routine in tango.core.Array; phobos provides
>> no such analogue. With phobos, either write your own routine, or
>> use std.c.stdlib.qsort. I'll let you decide which is more elegant.
>>
>
> It's not just a matter of elegance. C++ std::sort() is way, way
> faster than qsort in cstdlib because the comparison function gets
> inlined. Sorting is one place where inlining is critical.
I believe the intention for D is that the optimizer will automagically
inline everything it can.
Regan
More information about the Digitalmars-d
mailing list