prand

package
v0.0.0-...-643218b Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandBetweenInt

func RandBetweenInt(min, max uint) uint

[min, max) or [max, min) 只要较大不包含

func RandBetweenInt32

func RandBetweenInt32(min, max int32) int32

[min, max) or [max, min) 只要较大不包含

func RandBetweenInt64

func RandBetweenInt64(min, max int64) int64

[min, max) or [max, min) 只要较大不包含

func RandByMapWeight

func RandByMapWeight[K comparable, V IWeightable](m map[K]V) V

func RandByTotalWeight

func RandByTotalWeight(weight, total uint) bool

func RandByWeight

func RandByWeight(weights []uint) (int, uint)

rand by weight

func RandByWeightFunc

func RandByWeightFunc[T any](weights []T, weightFunc func(T) uint) (int, T)

func RandByWeightable

func RandByWeightable[T IWeightable](weights []T) (int, T)

func RandFlipArray

func RandFlipArray[T IWeightable](weights []T, chooseIndex int) ([]T, T)

rand flip 1.打乱顺序 2. 根据权重随机 3.交换选中

func RandFlipArrayMapFunc

func RandFlipArrayMapFunc[T IWeightable, K any](weights []T, chooseIndex int, mapFunc func(T) K) ([]K, K)

func RandInCMap

func RandInCMap[PK core.Hashable, V any](m cmap.ConcurrentMap[PK, V]) V

func RandMax

func RandMax(max uint) uint

[0, max) 只要较大不包含

func RandNByWeight

func RandNByWeight(weights []uint, n int) []uint

n>1

Types

type IWeightable

type IWeightable interface {
	GetWeight() uint
}

Jump to

Keyboard shortcuts

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