#shuffling a slice

1 messages · Page 1 of 1 (latest)

sleek valley
#

How do I shuffle a slice in zig?

versed lintel
#

std.rand.Random has a shuffle method

sleek valley
#

oops, completely missed that. thanks!

simple hound
#

(shameless plug) Total coincidence, but I just finished writing a shuffle library. It uses the stdlib under the hood, but if you want a shuffled copy and your individual data elements are larger than 4-8 bytes you can expect it to be a fair bit faster (reduced memory bandwidth by shuffling an index array and reading from that).