Sampling algorithms for D
Somedude
lovelydear at mailmetrash.com
Wed Apr 18 08:03:05 PDT 2012
Le 18/04/2012 05:15, Joseph Rushton Wakeling a écrit :
> On 13/04/12 10:04, Dmitry Olshansky wrote:
>>> OK, I'll see what I can do. I'd like to discuss and refine the design a
>>> bit further before making any pull request -- should I take things over
>>> to the Phobos mailing list for this ... ?
>>
>> I'm no authority but there is this d.D newsgroup which is perfectly
>> fine for
>> this kind of thing. A lot of nice people just don't (have time to)
>> mess with
>> unwashed masses in D.learn :)
>
> Tweaked version, an revision of RandomSample from std.random, is
> available from
> https://github.com/WebDrake/RandomSample
>
> Feedback on code details and on tests would be very welcome. It seems
> about 10% slower than the original code I wrote, which I guess is down
> to factors in the design of the RandomSample struct.
This looks very C++ ish.
I can't comment very much, being myself quite noob, but I think you can
do this, for style as well as performance:
- add pure nothrow everywhere you can.
- move some imports within the static if when possible, as close to
their actual usage, and it's better to do:
import core.time:clock_t, clock;
You may also want to use a bit of contract programming for input and output.
Also not sure the _ convention for private attributes is recommended in D.
More information about the Digitalmars-d-learn
mailing list