Documentation
¶
Overview ¶
Package fastrand exposes an object Rand which can be used as a simple drop-in replacement for `[math/rand.Rand]` where performance or thread safety is required.
Index ¶
- type Rand
- func (r Rand) Clone() tdigest.RNG
- func (r Rand) ExpFloat64() float64
- func (r Rand) Float32() float32
- func (r Rand) Float64() float64
- func (r Rand) Int() int
- func (r Rand) Int31() int32
- func (r Rand) Int31n(n int32) int32
- func (r Rand) Int63() int64
- func (r Rand) Int63n(n int64) int64
- func (r Rand) Intn(n int) int
- func (r Rand) NormFloat64() float64
- func (r Rand) Perm(n int) []int
- func (r Rand) Read(p []byte) (n int, err error)
- func (r Rand) Seed(seed int64)
- func (r Rand) Shuffle(n int, swap func(i int, j int))
- func (r Rand) Uint32() uint32
- func (r Rand) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rand ¶
type Rand struct{}
Rand is an object that behaves largely as-if it was a math/rand.Rand, with the key distinction that it is thread-safe and highly performant.
Under the hood this uses a thread-safe pool of math/rand.Rand objects which it will dynamically create and access for each call. As a result, this does not support setting the seed, since the underlying objects are ephemeral.
func (Rand) ExpFloat64 ¶
ExpFloat64 implements math/rand.Rand.ExpFloat64.
func (Rand) NormFloat64 ¶
NormFloat64 implements math/rand.Rand.NormFloat64.
func (Rand) Read ¶
Read implements math/rand.Rand.Read.
func (Rand) Shuffle ¶
Shuffle math/rand.Rand.Shuffle.