rand

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 6 Imported by: 0

Documentation

Overview

Package rand random digit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Intn

func Intn(n int) int

Intn 返回全局随机数

func SelectWeightedRandItem

func SelectWeightedRandItem(scalableRand *ScalableRand, slice WeightedSlice) int

SelectWeightedRandItem 通过随机权重算法选择值

Types

type ScalableRand

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

ScalableRand 可水平扩展的随机数发生器

func NewScalableRand

func NewScalableRand() *ScalableRand

NewScalableRand 初始化随机数发生器

func (*ScalableRand) Intn

func (s *ScalableRand) Intn(n int) int

Intn 获取随机数

type WeightedSlice

type WeightedSlice interface {
	search.SearchableSlice
	// TotalWeight 获取总权重值
	TotalWeight() int
}

WeightedSlice 带权重的数组

Jump to

Keyboard shortcuts

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