On 18.04.2012 19:03, Somedude wrote:
[snip]

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.

Yup, unless it's a template as its properties are deduced anyway.

  - 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;

Dubious.


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.

It's OK. The c++ is where it's questionable and primarily because it may collide with some internal macros of you compiler! (__cplusplus anyone?)

--
Dmitry Olshansky

Reply via email to