tavor: github.com/zimmski/tavor/rand Index | Files

package rand

import "github.com/zimmski/tavor/rand"

Index

Package Files

constant.go increment.go rand.go

type ConstantRand Uses

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 Uses

func NewConstantRand(seed int64) *ConstantRand

NewConstantRand returns a new instance of the constant random generator

func (*ConstantRand) Int Uses

func (r *ConstantRand) Int() int

Int returns a non-negative pseudo-random int

func (*ConstantRand) Int63 Uses

func (r *ConstantRand) Int63() int64

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

func (*ConstantRand) Int63n Uses

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 Uses

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 Uses

func (r *ConstantRand) Seed(seed int64)

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

type IncrementRand Uses

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 Uses

func NewIncrementRand(seed int64) *IncrementRand

NewIncrementRand returns a new instance of the increment random generator

func (*IncrementRand) Int Uses

func (r *IncrementRand) Int() int

Int returns a non-negative pseudo-random int

func (*IncrementRand) Int63 Uses

func (r *IncrementRand) Int63() int64

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

func (*IncrementRand) Int63n Uses

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 Uses

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 Uses

func (r *IncrementRand) Seed(seed int64)

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

type Rand Uses

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

Package rand is imported by 3 packages. Updated 2016-07-20. Refresh now. Tools for package owners.