Documentation
¶
Index ¶
- func RandBetweenInt(min, max uint) uint
- func RandBetweenInt32(min, max int32) int32
- func RandBetweenInt64(min, max int64) int64
- func RandByMapWeight[K comparable, V IWeightable](m map[K]V) V
- func RandByTotalWeight(weight, total uint) bool
- func RandByWeight(weights []uint) (int, uint)
- func RandByWeightFunc[T any](weights []T, weightFunc func(T) uint) (int, T)
- func RandByWeightable[T IWeightable](weights []T) (int, T)
- func RandFlipArray[T IWeightable](weights []T, chooseIndex int) ([]T, T)
- func RandFlipArrayMapFunc[T IWeightable, K any](weights []T, chooseIndex int, mapFunc func(T) K) ([]K, K)
- func RandInCMap[PK core.Hashable, V any](m cmap.ConcurrentMap[PK, V]) V
- func RandMax(max uint) uint
- func RandNByWeight(weights []uint, n int) []uint
- type IWeightable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandBetweenInt32 ¶
[min, max) or [max, min) 只要较大不包含
func RandBetweenInt64 ¶
[min, max) or [max, min) 只要较大不包含
func RandByMapWeight ¶
func RandByMapWeight[K comparable, V IWeightable](m map[K]V) V
func RandByTotalWeight ¶
func RandByWeightFunc ¶
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
Types ¶
type IWeightable ¶
type IWeightable interface {
GetWeight() uint
}
Click to show internal directories.
Click to hide internal directories.