Bug 4847 – std.algorithm.topN documentation

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-09-09T13:02:00Z
Last change time
2013-03-07T10:41:05Z
Assigned to
andrei
Creator
bearophile_hugs

Comments

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
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/3d5a203323d59181e121f5536bd76aa2a29509f7 Fix Issue 4847 - std.algorithm.topN documentation This was a quick fix so I'm doing it online.
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
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/29e043d4616a7d21fbdbd8102b95d01494750759 Fix Issue 4847 - std.algorithm.topN documentation Converted unittest into an example.
Comment #5 by andrei — 2013-03-07T10:41:05Z
Thanks for following through. Refixed, please reopen if needed.