Documentation
¶
Index ¶
Constants ¶
View Source
const K = 0x9e3779b97f4a7c13
proportionality factor
Variables ¶
This section is empty.
Functions ¶
Types ¶
type INumber ¶ added in v1.14.4
type INumber interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64
}
Define the types that can be used with RangeRandom The ~ operator allows for type sets that include all types that are assignable to the specified type. This includes all integer types, unsigned integer types, and floating-point types.
type WeightItem ¶
WeightItem is a weighted item.
type WeightPool ¶
WeightPool is a weighted random pool. It is used to select a random item from a list of items with different weights.
func NewWeightPool ¶
func NewWeightPool[T any, WT INumber](items []WeightItem[T, WT]) *WeightPool[T, WT]
func (*WeightPool[T, WT]) Random ¶
func (p *WeightPool[T, WT]) Random() T
Select a random item from the pool based on its weight. The probability of selecting an item is proportional to its weight. The higher the weight, the more likely it is to be selected.
func (*WeightPool[T, WT]) WithRngSource ¶ added in v1.14.4
WithRngSource .
Click to show internal directories.
Click to hide internal directories.