Documentation ¶
Index ¶
- func Samples(n uint, m uint, swap func(i, j uint)) error
- func Shuffle(n uint, swap func(i, j uint)) error
- func Uint() (uint, error)
- func Uint32() (uint32, error)
- func Uint32n(n uint32) (uint32, error)
- func Uint64() (uint64, error)
- func Uint64n(n uint64) (uint64, error)
- func Uintn(n uint) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Samples ¶
Samples picks randomly m elements out of n elemnts in a data structure and places them in random order at indices [0,m-1], the swapping being implemented in place. The data structure is defined by the `swap` function. Sampling is not deterministic.
It implements the first (m) elements of Fisher-Yates Shuffle using crypto/rand as a source of randoms.
O(1) space and O(m) time
func Shuffle ¶
Shuffle permutes a data structure in place based on the provided `swap` function. It is not deterministic.
It implements Fisher-Yates Shuffle using crypto/rand as a source of randoms.
O(1) space and O(n) time
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.