fastrand

package
v0.1.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Perm

func Perm(n uint32) []uint32

Perm returns a random permutation of the range [0,n).

func Probability

func Probability(prob uint32) bool

Probability 小于prob的概率, prob is in the range [0,1000)

func Random

func Random(ss []string) []string

Random return random string from string slice

func Read

func Read(b []byte)

Read is a helper function that calls rr.Read on b. It always fills b completely.

func Sampling

func Sampling(rate float32) bool

Sampling 采样率, [rate] is in the range [0,1)

func Shuffle

func Shuffle(n int, swap func(i, j int))

Shuffle pseudo-randomizes the order of elements.

n: is the number of elements. Shuffle panics if n < 0.
swap: swaps the elements with indexes i and j.

func Uint32

func Uint32() uint32

Uint32 returns pseudorandom uint32. It is safe calling this function from concurrent goroutines.

func Uint32n

func Uint32n(maxN uint32) uint32

Uint32n returns pseudorandom uint32 in the range [0...maxN). It is safe calling this function from concurrent goroutines.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL