randutil

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigIntN

func BigIntN(n *big.Int) *big.Int

BigIntN returns a uniform random *big.Int in [0,n). It panics if n <= 0.

func Bits

func Bits(b []byte)

func Bytes

func Bytes(n int) []byte

Bytes a helper function that returns n bytes of random data.

func Float64

func Float64() float64

Float64 implements rand.Float64 on the grpcrand global source.

func Int

func Int(min int, max int) int

Int returns a random integer in range [min, max].

func Int63n

func Int63n(n int64) int64

Int63n implements rand.Int63n on the grpcrand global source.

func IntN

func IntN(n int) int

IntN returns a uniform random int in [0,n). It panics if n <= 0.

func Intn

func Intn(n int) int

Intn implements rand.Intn on the grpcrand global source.

func Ints

func Ints(from, to, size int) []int

Ints returns a random integer array with the specified from, to and size.

func Perm

func Perm(n int) []int

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

func Probability

func Probability(prob float64) bool

Probability 小于prob的概率, prob is in [0.0,1.0)

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 Shuffle

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

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

func String

func String(n int) string

func Uint64n

func Uint64n(n uint64) uint64

Uint64n returns a uniform random uint64 in [0,n). It panics if n == 0.

Types

This section is empty.

Directories

Path Synopsis
Package fastrand implements fast pesudorandom number generator that should scale well on multi-CPU systems.
Package fastrand implements fast pesudorandom number generator that should scale well on multi-CPU systems.

Jump to

Keyboard shortcuts

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