rand

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int32

func Int32(n int32) int32

func Int64

func Int64(n int64) int64

func Random

func Random(min, max int32) int32

func RandomNum

func RandomNum(min, max, num int32) []int32

给定一个范围,随机若干个数

func RandomQSlice

func RandomQSlice(list interface{}, num int32, canRepeated bool) interface{}

从一个slice里面,根据权重,随机出value

可以重复的参数比不可重复效率略高

list := []struct{int32,interface{}}

切记不要修改返回值里面的内容

Types

type Rand

type Rand struct {
	// contains filtered or unexported fields
}

func New

func New() Rand

func (Rand) Int32

func (r Rand) Int32(n int32) int32

func (Rand) Int64

func (r Rand) Int64(n int64) int64

func (Rand) Random

func (r Rand) Random(min, max int32) int32

func (Rand) RandomNum

func (r Rand) RandomNum(min, max, num int32) []int32

给定一个范围,随机若干个数

func (Rand) RandomQSlice

func (r Rand) RandomQSlice(list interface{}, num int32, canRepeated bool) interface{}

从一个slice里面,根据权重,随机出value

可以重复的参数比不可重复效率略高

list := []struct{int32,interface{}}

切记不要修改返回值里面的内容

Jump to

Keyboard shortcuts

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