std.random.uniform for enums
Jakob Ovrum
jakobovrum at gmail.com
Wed Feb 12 19:05:28 PST 2014
On Thursday, 13 February 2014 at 03:04:06 UTC, Jakob Ovrum wrote:
> On Thursday, 13 February 2014 at 02:30:47 UTC, Frustrated wrote:
>> Could you not simply select one at random by "name"? Even
>> though
>> the values of the enum may not be sequential the keys are.
>
> Yeah, and there is apparently already an overload that does
> that.
>
> Regardless, I wrote a version that has an optimized path for
> sequential enums:
>
> https://gist.github.com/JakobOvrum/8968977
It's also worth noting that both the existing std.random.uniform
and the one I posted would fail when the base type of the enum
has mutable indirection.
More information about the Digitalmars-d-learn
mailing list