Documentation
¶
Index ¶
- func Float64() float64
- func Int() int
- func Int32() int32
- func Int64() int64
- func N[Int constraints.Integer](n Int) Int
- func Perm(n int) []int
- func Shuffle(n int, swap func(i, j int))
- func Uint32() uint32
- func Uint64() (x uint64)
- type Rand
- func (r *Rand) Float64() float64
- func (r *Rand) Int() int
- func (r *Rand) Int32() int32
- func (r *Rand) Int64() int64
- func (r *Rand) Perm(n int) []int
- func (r *Rand) Shuffle(n int, swap func(i, j int))
- func (r *Rand) Uint32() uint32
- func (r *Rand) Uint64() uint64
- func (r *Rand) Uint64N(n uint64) uint64
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float64 ¶
func Float64() float64
Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0).
func Int32 ¶ added in v2.12.0
func Int32() int32
Int32 returns a non-negative pseudo-random 31-bit integer as an int32.
func Int64 ¶ added in v2.12.0
func Int64() int64
Int64 returns a non-negative pseudo-random 63-bit integer as an int64.
func N ¶ added in v2.12.0
func N[Int constraints.Integer](n Int) Int
N returns a pseudo-random number in the half-open interval [0,n) from the default Source. The type parameter Int can be any integer type. It panics if n <= 0.
func Perm ¶
Perm returns, as a slice of n ints, a pseudo-random permutation of the integers in the half-open interval [0,n).
Types ¶
type Rand ¶ added in v2.12.0
type Rand struct {
// contains filtered or unexported fields
}
A Rand is a source of random numbers.
func New ¶ added in v2.12.0
New returns a new Rand that uses random values from src to generate other random values.
func (*Rand) Float64 ¶ added in v2.12.0
Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0).
func (*Rand) Int32 ¶ added in v2.12.0
Int32 returns a non-negative pseudo-random 31-bit integer as an int32.
func (*Rand) Int64 ¶ added in v2.12.0
Int64 returns a non-negative pseudo-random 63-bit integer as an int64.
func (*Rand) Perm ¶ added in v2.12.0
Perm returns, as a slice of n ints, a pseudo-random permutation of the integers in the half-open interval [0,n).
func (*Rand) Shuffle ¶ added in v2.12.0
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.