Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendWeightedRandomChoices ¶
AppendWeightedRandomChoices appends weighted randomized elements to a slice. The order of previously added elements in the result list is retained
Types ¶
type Choice ¶
Choice is a generic wrapper that can be used to add weights for any item.
type Chooser ¶
type Chooser[T any] struct { // contains filtered or unexported fields }
A Chooser caches many possible Choices in a structure designed to improve performance on repeated calls for weighted random selection.
func NewChooser ¶
NewChooser initializes a new Chooser for picking from the provided choices.
Click to show internal directories.
Click to hide internal directories.