Comment #0 by bearophile_hugs — 2010-09-09T13:02:12Z
This program seems correct (DMD 2.048):
import std.algorithm: topN;
void main() {
int[] a = [10, 1, 7];
topN(a, 10);
}
I'd like the documentation of topN to specify what does it happen when the specified 'nth' argument is bigger than the length of the given range.
And I think it's better to add an usage example of topN(r1, r2).
Comment #1 by github-bugzilla — 2013-03-04T15:39:47Z
Comment #2 by bearophile_hugs — 2013-03-04T17:36:08Z
Thank you. But the second part of the request is not fulfilled:
>And I think it's better to add an usage example of topN(r1, r2).<
The documentation of the second overload of TopN says:
void topN(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range1, Range2)(Range1 r1, Range2 r2);
Stores the smallest elements of the two ranges in the left-hand range.
Example:
Do you want me to reopen this?
(By the way, I have found an unfiled problem, topN uses uniform(), but I think the module doesn't import std.random).
Comment #3 by bearophile_hugs — 2013-03-04T18:39:41Z
OK, reopened, otherwise I will forget.
Comment #4 by github-bugzilla — 2013-03-07T10:39:52Z