rand

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoRepeatRand

type NoRepeatRand struct {
	Index uint32 // 随机标号,标记还剩下多少个可选数
	Seed  uint32 // 随机种子
	Count uint32 // 总数
	// contains filtered or unexported fields
}

快速不重复随机数 uint32 取值范围[0~4,294,967,295] 100,000,000 个数的内存开销约 400MB

func NewNoRepeatRand

func NewNoRepeatRand(start, end, seed uint32) *NoRepeatRand

[start,end]

func NewNoRepeatRandEx

func NewNoRepeatRandEx(start, end, seed, skip uint32) *NoRepeatRand

[start,end] skip 略过多少个

func (*NoRepeatRand) Append

func (r *NoRepeatRand) Append(array []uint32)

添加新的随机数,已经被使用过的随机数重复利用

func (*NoRepeatRand) GetCount

func (r *NoRepeatRand) GetCount() uint32

获取随机数池总数

func (*NoRepeatRand) GetRemainCount

func (r *NoRepeatRand) GetRemainCount() uint32

获取剩余随机个数

func (*NoRepeatRand) Random

func (r *NoRepeatRand) Random(count uint32) ([]uint32, error)

随机 count 个数

type Rand

type Rand struct {
	X0 uint32
}

func (*Rand) Rand

func (r *Rand) Rand() uint32

func (*Rand) RandAB

func (r *Rand) RandAB(A, B uint32) uint32

[A,B]

func (*Rand) Seed

func (r *Rand) Seed(seed uint32)

Jump to

Keyboard shortcuts

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