Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WeightedRandSelect ¶
type WeightedRandSelect[T comparable] struct { // contains filtered or unexported fields }
WeightedRandSelect は重み付き乱択を行います
func NewWeightedRandSelect ¶
func NewWeightedRandSelect[T comparable](items map[T]float64) (*WeightedRandSelect[T], error)
NewWeightedRandSelect は WeightedRandSelect を生成して返却します。 乱択対象の items は、key にアイテム固有のキー、value にアイテムの重みを指定してください。 アイテムの重み合計が0以下の場合、エラーを返却します。
func (*WeightedRandSelect[T]) Select ¶
func (ws *WeightedRandSelect[T]) Select() T
Select は ws に渡された重み付きアイテムの乱択を行います。
Click to show internal directories.
Click to hide internal directories.