rand

package
v0.0.0-...-9f34108 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstantRand

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

ConstantRand implements a constant random generator. This generator returns the defined seed every time, unless a method has a bound then it returns at most the given bound. It is therefore not random at all and can be safely used when deterministic values are needed.

func NewConstantRand

func NewConstantRand(seed int64) *ConstantRand

NewConstantRand returns a new instance of the constant random generator

func (*ConstantRand) Int

func (r *ConstantRand) Int() int

Int returns a non-negative pseudo-random int

func (*ConstantRand) Int63

func (r *ConstantRand) Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func (*ConstantRand) Int63n

func (r *ConstantRand) Int63n(n int64) int64

Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*ConstantRand) Intn

func (r *ConstantRand) Intn(n int) int

Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*ConstantRand) Seed

func (r *ConstantRand) Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state.

type IncrementRand

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

IncrementRand implements an incrementing random generator. This generator returns beginning from 0 an incremented value on every call. If the defined seed is equal or greater to the current generator value, the generator resets its value to 0. The generator will reset itself also to zero, if a method has a bound and the current generator value is equal or greater to the bound.

func NewIncrementRand

func NewIncrementRand(seed int64) *IncrementRand

NewIncrementRand returns a new instance of the increment random generator

func (*IncrementRand) Int

func (r *IncrementRand) Int() int

Int returns a non-negative pseudo-random int

func (*IncrementRand) Int63

func (r *IncrementRand) Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func (*IncrementRand) Int63n

func (r *IncrementRand) Int63n(n int64) int64

Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*IncrementRand) Intn

func (r *IncrementRand) Intn(n int) int

Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*IncrementRand) Seed

func (r *IncrementRand) Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state.

type Rand

type Rand interface {
	// Int returns a non-negative pseudo-random int
	Int() int
	// Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0.
	Intn(n int) int
	// Int63 returns a non-negative pseudo-random 63-bit integer as an int64.
	Int63() int64
	// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). It panics if n <= 0.
	Int63n(n int64) int64
	// Seed uses the provided seed value to initialize the generator to a deterministic state.
	Seed(seed int64)
}

Rand defines random data generator for the Tavor framework

Jump to

Keyboard shortcuts

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