fn shuffleWithIndex(r: Random, comptime T: type, buf: []T, comptime Index: type) void

Shuffle a slice into a random order, using an index of a specified type to maintain distribution across targets. Asserts the index type can represent buf.len.

Indexes into the slice are generated using the specified Index type, which determines distribution properties. This allows for results to be independent of usize representation.

Prefer shuffle if this isn’t important.

See intRangeLessThan, which this function uses, for commentary on the runtime of this function.

Parameters

r: Random,
T: type,
buf: []T,
Index: type,