weightedchoice

package
v1.23.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

Factory create a mask from a yaml config

func Func added in v1.15.0

func Func(seed int64, seedField string) interface{}

Types

type Choice

type Choice struct {
	Item   interface{}
	Weight uint
}

Choice is a wrapper of item and its weight

type Chooser

type Chooser struct {
	// contains filtered or unexported fields
}

A Chooser is to choose a Choice by weight

func NewChooser

func NewChooser(seed int64, cs ...Choice) Chooser

NewChooser creates a Chooser from Choices

func (Chooser) Pick

func (chs Chooser) Pick() interface{}

Pick returns a choice from a Chooser

type MaskEngine

type MaskEngine struct {
	// contains filtered or unexported fields
}

MaskEngine a list of masking value with weight for random

func NewMask

func NewMask(list []model.WeightedChoiceType, seed int64, seeder model.Seeder) MaskEngine

NewMask returns a WeightedMaskList from slice of model.Entry and weights

func (MaskEngine) Mask

func (wml MaskEngine) Mask(e model.Entry, context ...model.Dictionary) (model.Entry, error)

Mask choose a mask value randomly

Jump to

Keyboard shortcuts

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