random

package
v1.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 4

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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