Adding Radix Sort into Phobos

via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 28 08:21:48 PDT 2015


On Monday, 27 April 2015 at 20:54:36 UTC, Andrei Alexandrescu 
wrote:
> Yah, these are good angles/ideas. I'm curious, how come 
> radixSort on long is better than quicksort? Conventional wisdom 
> has it that quicksort is better for large-ish integral types. 
> What data distributions did you test on? -- Andrei

I just realized that I should make radiSort @nogc by using

     import std.container.array: Array;
     Array!Elem y;

instead of

     Elem[] y;

By

     import std.container.array: Array;
     import std.array: uninitializedArray;
     alias A = Array!Elem;
     auto y = uninitializedArray!A(n);

fails as

intsort.d(222,38): Error: template std.array.uninitializedArray 
cannot deduce function from argument types 
!(Array!byte)(immutable(ulong)), candidates are:

How do I void allocate it then?


More information about the Digitalmars-d mailing list