fastrand

package
v1.32.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 3 Imported by: 0

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

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) Clone

func (r Rand) Clone() tdigest.RNG

Clone method is a no-op to support use in tdigest library.

func (Rand) ExpFloat64

func (r Rand) ExpFloat64() float64

ExpFloat64 implements math/rand.Rand.ExpFloat64.

func (Rand) Float32

func (r Rand) Float32() float32

Float32 implements math/rand.Rand.Float32.

func (Rand) Float64

func (r Rand) Float64() float64

Float64 implements math/rand.Rand.Float64.

func (Rand) Int

func (r Rand) Int() int

Int implements math/rand.Rand.Int.

func (Rand) Int31

func (r Rand) Int31() int32

Int31 implements math/rand.Rand.Int31.

func (Rand) Int31n

func (r Rand) Int31n(n int32) int32

Int31n implements math/rand.Rand.Int31n.

func (Rand) Int63

func (r Rand) Int63() int64

Int63 implements math/rand.Rand.Int63.

func (Rand) Int63n

func (r Rand) Int63n(n int64) int64

Int63n implements math/rand.Rand.Int63n.

func (Rand) Intn

func (r Rand) Intn(n int) int

Intn implements math/rand.Rand.Intn.

func (Rand) NormFloat64

func (r Rand) NormFloat64() float64

NormFloat64 implements math/rand.Rand.NormFloat64.

func (Rand) Perm

func (r Rand) Perm(n int) []int

Perm implements math/rand.Rand.Perm.

func (Rand) Read

func (r Rand) Read(p []byte) (n int, err error)

Read implements math/rand.Rand.Read.

func (Rand) Seed

func (r Rand) Seed(seed int64)

Seed implements math/rand.Rand.Seed.

func (Rand) Shuffle

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

Shuffle math/rand.Rand.Shuffle.

func (Rand) Uint32

func (r Rand) Uint32() uint32

Uint32 implements math/rand.Rand.Uint32.

func (Rand) Uint64

func (r Rand) Uint64() uint64

Uint64 implements math/rand.Rand.Uint64.

Jump to

Keyboard shortcuts

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