topNIndex

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Jan 22 12:42:09 PST 2015


On 1/22/15 11:50 AM, H. S. Teoh via Digitalmars-d wrote:
> There's an undocumented function (2 overloads) called topNIndex that's
> still sitting in std.algorithm.package, 'cos I have no idea what it does
> and where it belongs.
>
> 1) Do we still want this function?

Yes.

> 2) There's a bunch of dead code that has been commented out since 2009,
> including a function named topNIndexImpl. Does that mean that topNIndex
> is also dead code?

topNIndex is supposed to be public.

> 3) What is this function supposed to do? (OK OK, I can just read the
> code, but I figured it's faster to ask here. :-P)

void topNIndex(
     alias less = "a < b",
     SwapStrategy ss = SwapStrategy.unstable,
     Range, RangeIndex)(Range r, RangeIndex index, SortOutput sorted = 
SortOutput.no)
if (isIntegral!(ElementType!(RangeIndex)));

It stores the indices of the top `index.length` elements of `r` in 
`index`, without modifying `r`.

> 4) Should we keep it, or should we chuck it?

Keep.


Andrei



More information about the Digitalmars-d mailing list