Documentation ΒΆ
Index ΒΆ
Constants ΒΆ
This section is empty.
Variables ΒΆ
View Source
var ( // ErrNoValidOptions is used and returned when no Options are found with a Weight >= 1. ErrNoValidOptions = errors.New("no Options found with Weight >= 1") // ErrWeightOverflow is used and returned when the sum of all Option weights exceeds the max integer value for this system's architecture. ErrWeightOverflow = errors.New("Option weight exceeds max integer value for this system's architecture") )
Functions ΒΆ
This section is empty.
Types ΒΆ
type Option ΒΆ
type Option[DataType any, WeightIntegerType WeightIntegerConstraint] struct { Data DataType Weight WeightIntegerType }
Option is a struct that holds a data value and its associated weight.
func NewOption ΒΆ
func NewOption[DataType any, WeightIntegerType WeightIntegerConstraint]( data DataType, weight WeightIntegerType, ) Option[DataType, WeightIntegerType]
NewOption creates a new Option with the provided data and weight.
type Selector ΒΆ
type Selector[DataType any, WeightIntegerType WeightIntegerConstraint] struct { // contains filtered or unexported fields }
Selector is a struct that holds a slice of Options, their running total weights, and the total weight.
func NewSelector ΒΆ
func NewSelector[DataType any, WeightIntegerType WeightIntegerConstraint]( options ...Option[DataType, WeightIntegerType], ) (*Selector[DataType, WeightIntegerType], error)
NewSelector creates a new Selector for selecting provided Options.
Click to show internal directories.
Click to hide internal directories.