Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Rand = rands{ // contains filtered or unexported fields }
Rand 是一个全局的 rands 实例,用于在整个程序中生成随机数。 它使用当前时间的毫秒值作为随机源,以确保每次程序运行时都能获得不同的随机数序列。
Functions ¶
func RandByArrInt ¶
RandByArrInt 函数从一个整数数组中按权重选择一个索引,并返回该索引。 权重是数组中相应元素的值。该函数通过计算累积和来确定选择的索引。 参数 v 是一个泛型参数,限制为实现了 Number 接口的类型。 返回值是一个整数,表示在数组中的索引。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.