fastrand

package
v0.0.0-...-052ef2a Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package fastrand is the fastest pseudorandom number generator in Go(multiple-cores).

Index

Constants

This section is empty.

Variables

View Source
var Uint32 = Fastrand

Uint32 returns a pseudo-random 32-bit value as a uint32.

Functions

func Fastrand

func Fastrand() uint32

func Float32

func Float32() float32

func Float64

func Float64() float64

func Int

func Int() int

Int returns a non-negative pseudo-random int.

func Int31

func Int31() int32

Int31 returns a non-negative pseudo-random 31-bit integer as an int32.

func Int31n

func Int31n(n int32) int32

Int31n returns, as an int32, a non-negative pseudo-random number in [0,n). It panics if n <= 0. For implementation details, see: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction

func Int63

func Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func Int63n

func Int63n(n int64) int64

Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func Intn

func Intn(n int) int

Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func Perm

func Perm(n int) []int

Perm returns, as a slice of n ints, a pseudo-random permutation of the integers in the half-open interval [0,n).

func Read

func Read(p []byte) (int, error)

Read generates len(p) random bytes and writes them into p. It always returns len(p) and a nil error. It is safe for concurrent use.

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 Uint32n

func Uint32n(n uint32) uint32

Uint32n returns a pseudo-random number in [0,n).

func Uint64

func Uint64() uint64

Uint64 returns a pseudo-random 64-bit value as a uint64.

func Uint64n

func Uint64n(n uint64) uint64

Uint64n returns a pseudo-random number in [0,n).

Types

This section is empty.

Jump to

Keyboard shortcuts

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