weightedchoice

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

func Factory(conf model.Masking, seed int64, caches map[string]model.Cache) (model.MaskEngine, bool, error)

Factory create a mask from a yaml config

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) 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