Documentation ¶
Index ¶
- Constants
- func GetRandomNumber(args string, n int, radom *rand.Rand) []int
- func GetRandomNumbers(args string, radom *rand.Rand) []int
- func GetRandomValues(numbers []int, n int) []int
- func GetRandomValuesInt64(numbers []int64, n int) []int64
- func GetRandomWeight(data RandInterface, n int, radom *rand.Rand) interface{}
- func RandInt(min int, max int) int
- func RandInt32(min int32, max int32) int32
- func RandInt64(min int64, max int64) int64
- type LCGRand
- type RandInterface
- type RandItem
Constants ¶
View Source
const ( LCG_A uint32 = 1664525 LCG_C uint32 = 1013904223 )
Variables ¶
This section is empty.
Functions ¶
func GetRandomNumber ¶
*
- 数值抽取器(从枚举值,范围随机值,定值 中随机抽出一个值)
- 枚举值(支持单个出现概率):1,2,4 或 1:10,2:30,4:30
- 范围值: 1~10
- 定值:12
- 支持混合使用 如:1~10,44~89,2~5 又如 2~10:40
- 支持概率后缀 代表该值被抽取出来的几率 值越高被抽出的概率越大 并不限定后缀值的范围 如:1:20,1~4:30,4:500 *
- @param args
- @param n 随机个数
- @param radom
- @return
func GetRandomNumbers ¶
*
- 加权随机数 数值抽取器 *
- @param args 以“#”劈分数组然后再在数组元素中每一位获取一个随机数
- @param radom
- @see #GetRandomNumber(String, Random)
- @return
func GetRandomWeight ¶
func GetRandomWeight(data RandInterface, n int, radom *rand.Rand) interface{}
GetRandomWeight 随机数选取
Types ¶
type LCGRand ¶
type LCGRand struct {
// contains filtered or unexported fields
}
func NewLCGRand ¶
func (*LCGRand) RandFloat64 ¶
type RandInterface ¶
RandInterface 随机数选取器接口
Click to show internal directories.
Click to hide internal directories.