rand

package
v0.0.0-...-8b45bad Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package rand 提供官方 math/rand 的一些小工具封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexByRatios

func IndexByRatios[T any, N constraints.Integer](config []T, ratioGetter func(i int, v T) N) int

IndexByRatios 抽奖。 按照给定的比例, 随机选择一个选项。如果一个选项 <= 0 则表示不可能被选中。如果选项列表长度为 0 或者所有选项比例的总和 <= 0 则返回 -1。

Types

This section is empty.

Jump to

Keyboard shortcuts

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