Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LockGuardedRand = NewLockedRand()
LockGuardedRand is a global lock protected random source ready to be used.
Functions ¶
func ShuffleStringList ¶
func ShuffleStringList(a []string)
ShuffleStringList shuffles the specified string slice.
Types ¶
type LockedRand ¶
type LockedRand struct {
// contains filtered or unexported fields
}
LockedRand a mutex protected random source.
func NewLockedRand ¶
func NewLockedRand() *LockedRand
NewLockedRand returns a new LockedRand instance.
func (*LockedRand) Uint64 ¶
func (r *LockedRand) Uint64() uint64
Uint64 returns a new random uint64 value.
type Probability ¶
type Probability struct {
// contains filtered or unexported fields
}
Probability is used to represent a random probability.
func NewProbability ¶
func NewProbability(outOfMillion uint64) *Probability
NewProbability returns a new Probability instance, the probability is is expressed a outOfMillion / one million, e.g. NewProbability(1) means there is 1 out of 1 million chance.
func (*Probability) Hit ¶
func (p *Probability) Hit() bool
Hit returns a boolean value indicating whether the random event is within the specified random range.
func (*Probability) Missed ¶
func (p *Probability) Missed() bool
Missed returns a boolean value indicating whether the random event is not within the specified random range.