Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Shuffle ¶
func Shuffle[R Uint64NGenerator, S ~[]T, T any](r R, s S) S
Shuffle randomly shuffles the elements in the slice.
func ShuffleN ¶
func ShuffleN[R Uint64NGenerator, S ~[]T, T any](r R, s S, n int) S
ShuffleN randomly selects and shuffles the first n elements from the entire slice. It ensures that the first n elements are randomly chosen from the whole slice, not just shuffled among themselves. Elements after the nth position may also be affected. This differs from a complete shuffle as it only guarantees randomness for the first n elements. It panics if n is negative or greater than the length of the slice.
Types ¶
type Uint64NGenerator ¶
Uint64NGenerator is an interface for generating random uint64 numbers in the range [0, n).
Click to show internal directories.
Click to hide internal directories.