shuffle a character array

celavek via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 20 01:18:55 PDT 2016


On Wednesday, 20 July 2016 at 08:02:07 UTC, Mike Parker wrote:
>
> If you are absolutely, 100% certain that you are dealing with 
> ASCII, you can do this:
>
> ```
> import std.string : representation;
> randomShuffle(charArray.representation);
>
> That will give you a ubyte[] for char[] and a ushort[] for 
> wchar[].
>
> [1] https://dlang.org/phobos/std_random.html#.randomShuffle
> [2] 
> https://dlang.org/phobos/std_range_primitives.html#isRandomAccessRange

Ahhh! That again. I was thinking about using the representation. 
I should take a deeper
look at the documentation.

As far as my current understanding goes the shuffle will be done 
in place.
If I use the "representation" would that still hold, that is will 
I be able
to use the same char[] but in the shuffled form? (of course I 
will test that)

Thank you


More information about the Digitalmars-d-learn mailing list