rand

package
v0.0.0-...-26bcfa9 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 2 Imported by: 0

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 に渡された重み付きアイテムの乱択を行います。

Jump to

Keyboard shortcuts

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