partition(range, leftsubrange) or partition(range, rightsubrange)
Benji Smith
dlanguage at benjismith.net
Wed Sep 10 21:33:27 PDT 2008
Sean Kelly wrote:
> Benji Smith wrote:
>> Why does tango's partition use a bool predicate instead of an int
>> predicate (returning -1, 0, or 1 like opCmp does)?
>
> Simply because it's more natural. I don't really like having to store
> the result of a compare and then switch off it.
>
>> Using the int predicate would enable a qsort routine that avoids
>> pointlessly swapping adjacent elements if they have equal values. It's
>> very handy for collections with lots of duplicate entries.
>
> Tango's sort routine already optimizes for duplicate entries. Partition
> and whatnot don't though.
>
>
> Sean
Gotcha. Thanks for the reply!
--benji
More information about the Digitalmars-d-announce
mailing list