utility

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Rand = rands{
	// contains filtered or unexported fields
}

Rand 是一个全局的 rands 实例,用于在整个程序中生成随机数。 它使用当前时间的毫秒值作为随机源,以确保每次程序运行时都能获得不同的随机数序列。

Functions

func RandByArrInt

func RandByArrInt[v tools.Number](s []v) int

RandByArrInt 函数从一个整数数组中按权重选择一个索引,并返回该索引。 权重是数组中相应元素的值。该函数通过计算累积和来确定选择的索引。 参数 v 是一个泛型参数,限制为实现了 Number 接口的类型。 返回值是一个整数,表示在数组中的索引。

Types

This section is empty.

Jump to

Keyboard shortcuts

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