Documentation
¶
Index ¶
- func ChooseKInPlace[T any](rng interface{ ... }, a []T, k int) []T
- func ChooseKWithReplacement[T any](rng *rand.Rand, bag []T, k int) []T
- func FillSliceRaw[T any](dst []T, rng rand.Source64)
- func NewRNG() *rand.Rand
- func NewRaw[T any](rng rand.Source64) (t T)
- func PopRandom[T any](rng interface{ ... }, a []T) (remaining []T, popped T)
- func SliceOf[T any](rng rand.Source64, len int) []T
- func UpperAlphanumericString(rng *rand.Rand, n int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseKInPlace ¶
ChooseKInPlace chooses N elements from the sample without replacement. This modifies the original slice and hands back a _sub-slice_. If this isn't what you want, copy the slice first.
func ChooseKWithReplacement ¶
ChooseKWithReplacement chooses k not-necessarially-distinct elements from a bag of items.
func FillSliceRaw ¶
FillSliceRaw fills the slice with randomly generated values of T. This is not safe for all types: see NewRaw.
func NewRNG ¶
NewRNG creates a new, NON-thread-safe, NON-cryptographically seucre rng, initializing the seed via crypto/rand.Int.
func NewRaw ¶
NewRaw generates a random element of T from completely random bits. This is only defined for the following types: non-string primitives, primitive integers, floats, complex numbers, booleans, and arrays and structs (recursively) comprised of those types. Floats and Complex numbers may not give a USEFUL result: subnormal numbers, NaNs, and +/- infinity may all result. That is, the following types are OK: int8..=int64, uint8..=uint64, bool, []int8..=int64, struct{x, y, z int}, [20]struct{x, y, z int}
Types ¶
This section is empty.