topN using a heap

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 19 10:27:17 PST 2016


On 01/19/2016 04:33 PM, Andrei Alexandrescu wrote:
> On 01/19/2016 08:10 AM, Andrei Alexandrescu wrote:
>> So anyhow we need the "intro" part. I'll get to that soon.
>
> Destroy! I made it part of
> https://github.com/D-Programming-Language/phobos/pull/3934.
>
> https://github.com/andralex/phobos/commit/4ba95cd1bd5124b53324c441e62c51d759481b04
> ...

The switching heuristic is bad. It always switches after at most 8 steps.

I'd just use the second heuristic discussed in 
https://en.wikipedia.org/wiki/Introselect .


More information about the Digitalmars-d mailing list