random

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 6 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 any, 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[T Slice](slice T, 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 Slice added in v0.1.0

type Slice interface {
	Len() int
	Swap(i, j 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
}

Jump to

Keyboard shortcuts

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