Documentation
¶
Index ¶
- Variables
- type Option
- type SearchIntsFuncSignature
- type Selector
- func NewSelector[DataType any, WeightIntegerType WeightIntegerConstraint](options ...Option[DataType, WeightIntegerType]) (*Selector[DataType, WeightIntegerType], error)
- func NewSelectorUsingSortSearchInts[DataType any, WeightIntegerType WeightIntegerConstraint](options ...Option[DataType, WeightIntegerType]) (*Selector[DataType, WeightIntegerType], error)
- func NewSelectorWithCustomSearchIntsFunc[DataType any, WeightIntegerType WeightIntegerConstraint](searchIntsFunc SearchIntsFuncSignature, ...) (*Selector[DataType, WeightIntegerType], error)
- type WeightIntegerConstraint
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWeightOverflow = errors.New("sum of Option weights exceeds total") ErrNoValidOptions = errors.New("0 Option(s) with Weight >= 1") )
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.
type SearchIntsFuncSignature ¶
SearchIntsFuncSignature is the signature of the function used to search for an integer in a sorted slice of integers.
type Selector ¶
type Selector[DataType any, WeightIntegerType WeightIntegerConstraint] struct { // contains filtered or unexported fields }
Selector is a struct that holds a slice of Options and their cumulative weights.
func NewSelector ¶
func NewSelector[DataType any, WeightIntegerType WeightIntegerConstraint]( options ...Option[DataType, WeightIntegerType], ) (*Selector[DataType, WeightIntegerType], error)
NewSelector creates a new Selector.
func NewSelectorUsingSortSearchInts ¶
func NewSelectorUsingSortSearchInts[DataType any, WeightIntegerType WeightIntegerConstraint]( options ...Option[DataType, WeightIntegerType], ) (*Selector[DataType, WeightIntegerType], error)
NewSelectorUsingSortSearchInts creates a new Selector using the sort.SearchInts function.
func NewSelectorWithCustomSearchIntsFunc ¶
func NewSelectorWithCustomSearchIntsFunc[DataType any, WeightIntegerType WeightIntegerConstraint]( searchIntsFunc SearchIntsFuncSignature, options ...Option[DataType, WeightIntegerType], ) (*Selector[DataType, WeightIntegerType], error)
NewSelectorWithCustomSearchIntsFunc creates a new Selector with a custom searchIntsFunc.
Click to show internal directories.
Click to hide internal directories.