random

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	O_DIGIT = 1 << iota
	O_LOWER_CHAR
	O_UPPER_CHAR
	O_SPECIAL_CHAR
)

Variables

This section is empty.

Functions

func Bool

func Bool(source Source) bool

func Index

func Index(d FiniteDistribution, source Source) int

func IndexInts

func IndexInts(d []int, source Source) int

func IndexSlice

func IndexSlice(d interface{}, probability func(int) int, source Source) int

func Int63

func Int63(source Source) int64

func Intn

func Intn(n int, source Source) int

func Perm

func Perm(n int, source Source) []int

func Shuffle

func Shuffle(orders SwapableSlice, source Source)

func ShuffleFloats

func ShuffleFloats(orders []float64, source Source)

func ShuffleInts

func ShuffleInts(orders []int, source Source)

func ShuffleSlice

func ShuffleSlice(slice interface{}, source Source)

func ShuffleStrings

func ShuffleStrings(orders []string, source Source)

func String

func String(length int, source Source, modes ...int) string

Types

type FiniteDistribution

type FiniteDistribution interface {
	Len() int
	Probability(i int) int
}

FiniteDistribution represents probability distribution

type IntsFiniteDistribution

type IntsFiniteDistribution []int

func (IntsFiniteDistribution) Len

func (d IntsFiniteDistribution) Len() int

func (IntsFiniteDistribution) Probability

func (d IntsFiniteDistribution) Probability(i int) int

type Source

type Source interface {
	Int63() int64
}
var (
	DefaultSource Source = newDefaultSource(time.Now().UnixNano())
	CryptoSource  Source = cryptoSource{}
)

type SummedFiniteDistribution

type SummedFiniteDistribution interface {
	FiniteDistribution
	SumProbability() int
}

type SwapableSlice

type SwapableSlice interface {
	Len() int
	Swap(i, j int)
}

Jump to

Keyboard shortcuts

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