Documentation
¶
Index ¶
- Variables
- func Float32() float32
- func Float64() float64
- func Int31n(n int32) int32
- func Int63n(n int64) int64
- func Intn(n int) int
- func NonWeightedChoice(weightArray []int) int
- func RandomChoice[T any](array []T, n int) []T
- func RandomInt(min, max int) int
- func RandomInt32(min, max int32) int32
- func RandomInt64(min, max int64) int64
- func RandomString(l int) string
- func Seed(seedType SeedType) int64
- func Shuffle[T any](array []T)
- func WeightedChoice(weightArray []int) int
- type Randomizer
- func (r *Randomizer) Float32() float32
- func (r *Randomizer) Float64() float64
- func (r *Randomizer) Int() int
- func (r *Randomizer) Int31() int32
- func (r *Randomizer) Int31n(n int32) int32
- func (r *Randomizer) Int63() int64
- func (r *Randomizer) Int63n(n int64) int64
- func (r *Randomizer) Intn(n int) int
- func (r *Randomizer) NonWeightedChoice(weightArray []int) int
- func (r *Randomizer) RandomString(l int) string
- func (r *Randomizer) RangeFloat32(min, max float32) float32
- func (r *Randomizer) RangeFloat64(min, max float64) float64
- func (r *Randomizer) RangeInt(min, max int) int
- func (r *Randomizer) RangeInt32(min, max int32) int32
- func (r *Randomizer) RangeInt64(min, max int64) int64
- func (r *Randomizer) RangeUint(min, max uint) uint
- func (r *Randomizer) RangeUint32(min, max uint32) uint32
- func (r *Randomizer) RangeUint64(min, max uint64) uint64
- func (r *Randomizer) Uint32() uint32
- func (r *Randomizer) Uint64() uint64
- func (r *Randomizer) WeightedChoice(weightArray []int) int
- type SeedType
- type Seeder
Constants ¶
This section is empty.
Variables ¶
View Source
var Alpha = "abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
Functions ¶
func NonWeightedChoice ¶
NonWeightedChoice 根据权重随机,返回对应选项的索引,O(n). 权重大于等于0
func WeightedChoice ¶
WeightedChoice 根据权重随机,返回对应选项的索引,O(n)
Types ¶
type Randomizer ¶
type Randomizer struct {
// contains filtered or unexported fields
}
func NewRandomizer ¶
func NewRandomizer(seedType SeedType) *Randomizer
func (*Randomizer) Float32 ¶
func (r *Randomizer) Float32() float32
func (*Randomizer) Float64 ¶
func (r *Randomizer) Float64() float64
func (*Randomizer) Int ¶
func (r *Randomizer) Int() int
func (*Randomizer) Int31 ¶
func (r *Randomizer) Int31() int32
func (*Randomizer) Int31n ¶
func (r *Randomizer) Int31n(n int32) int32
func (*Randomizer) Int63 ¶
func (r *Randomizer) Int63() int64
func (*Randomizer) Int63n ¶
func (r *Randomizer) Int63n(n int64) int64
func (*Randomizer) Intn ¶
func (r *Randomizer) Intn(n int) int
func (*Randomizer) NonWeightedChoice ¶
func (r *Randomizer) NonWeightedChoice(weightArray []int) int
NonWeightedChoice 根据权重随机,返回对应选项的索引,O(n). 权重大于等于0
func (*Randomizer) RandomString ¶
func (r *Randomizer) RandomString(l int) string
RandomString 随机字符串,包含大小写字母和数字
func (*Randomizer) RangeFloat32 ¶
func (r *Randomizer) RangeFloat32(min, max float32) float32
RangeFloat32 根据区间产生随机数
func (*Randomizer) RangeFloat64 ¶
func (r *Randomizer) RangeFloat64(min, max float64) float64
RangeFloat64 根据区间产生随机数
func (*Randomizer) RangeInt32 ¶
func (r *Randomizer) RangeInt32(min, max int32) int32
RangeInt32 根据区间产生随机数
func (*Randomizer) RangeInt64 ¶
func (r *Randomizer) RangeInt64(min, max int64) int64
RangeInt64 根据区间产生随机数
func (*Randomizer) RangeUint ¶
func (r *Randomizer) RangeUint(min, max uint) uint
RangeUint 根据区间产生随机数
func (*Randomizer) RangeUint32 ¶
func (r *Randomizer) RangeUint32(min, max uint32) uint32
RangeUint32 根据区间产生随机数
func (*Randomizer) RangeUint64 ¶
func (r *Randomizer) RangeUint64(min, max uint64) uint64
RangeUint64 根据区间产生随机数
func (*Randomizer) Uint32 ¶
func (r *Randomizer) Uint32() uint32
func (*Randomizer) Uint64 ¶
func (r *Randomizer) Uint64() uint64
func (*Randomizer) WeightedChoice ¶
func (r *Randomizer) WeightedChoice(weightArray []int) int
WeightedChoice 根据权重随机,返回对应选项的索引,O(n)
type Seeder ¶
type Seeder struct {
// contains filtered or unexported fields
}
func (*Seeder) CryptoRand ¶
func (*Seeder) RandomString ¶
Click to show internal directories.
Click to hide internal directories.