Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparable ¶
type Comparable interface {
Compare(to Comparable) bool
}
Interface for items that can be used along with WeightedRandomList
type Entry ¶
type Entry struct { Item Comparable Weight float32 }
Structure of each entry to select from
type WeightedRandomList ¶
type WeightedRandomList interface { Get() Comparable GetWithSeed(seed rand.Source) (Comparable, error) List() []Comparable Len() int }
Interface to use the Weighted Random
func NewWeightedRandom ¶
func NewWeightedRandom(ctx context.Context, entries []Entry) (WeightedRandomList, error)
Given a list of entries with weights, returns WeightedRandomList
Click to show internal directories.
Click to hide internal directories.