digitalmars.D - topNIndex
- H. S. Teoh via Digitalmars-d (13/13) Jan 22 2015 There's an undocumented function (2 overloads) called topNIndex that's
- Andrei Alexandrescu (13/23) Jan 22 2015 topNIndex is supposed to be public.
- H. S. Teoh via Digitalmars-d (11/42) Jan 22 2015 [...]
- Andrei Alexandrescu (3/5) Jan 22 2015 Most likely not. If you have the time, please take it to completion;
- H. S. Teoh via Digitalmars-d (8/14) Jan 22 2015 https://github.com/D-Programming-Language/phobos/pull/2898
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? 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? 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) 4) Should we keep it, or should we chuck it? T -- This is not a sentence.
Jan 22 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
Jan 22 2015
On Thu, Jan 22, 2015 at 12:42:09PM -0800, Andrei Alexandrescu via Digitalmars-d wrote:On 1/22/15 11:50 AM, H. S. Teoh via Digitalmars-d wrote:[...] Hmm. I'm looking over the code, and it appears that the implementation is incomplete. The compile-time parameter SwapStrategy is never used in the function bodies, for example, and the signature constraints fail to verify range operations freely employed (like opIndex, etc). Do we really want to publicly document this function before we clean it up? T -- Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- Carl B. ConstantineThere'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.
Jan 22 2015
On 1/22/15 1:09 PM, H. S. Teoh via Digitalmars-d wrote:Do we really want to publicly document this function before we clean it up?Most likely not. If you have the time, please take it to completion; otherwise leave it deleted. -- Andrei
Jan 22 2015
On Thu, Jan 22, 2015 at 01:24:55PM -0800, Andrei Alexandrescu via Digitalmars-d wrote:On 1/22/15 1:09 PM, H. S. Teoh via Digitalmars-d wrote:https://github.com/D-Programming-Language/phobos/pull/2898 I decided not to attempt implementing SwapStrategy, but at least document the current limitations. I think in spite of its limitations topNIndex is probably still useful in its present form. T -- The early bird gets the worm. Moral: ewww...Do we really want to publicly document this function before we clean it up?Most likely not. If you have the time, please take it to completion; otherwise leave it deleted. -- Andrei
Jan 22 2015