rand.wyrand #

struct WyRandRNG #

struct WyRandRNG {
mut:
	state     u64 = seed.time_seed_64()
	has_extra bool
	extra     u32
}

WyRandRNG is a RNG based on the WyHash hashing algorithm.

fn (WyRandRNG) f32 #

fn (mut rng WyRandRNG) f32() f32

f32 returns a pseudorandom f32 value in range [0, 1).

fn (WyRandRNG) f32_in_range #

fn (mut rng WyRandRNG) f32_in_range(min f32, max f32) f32

f32_in_range returns a pseudorandom f32 in range [min, max).

fn (WyRandRNG) f32n #

fn (mut rng WyRandRNG) f32n(max f32) f32

f32n returns a pseudorandom f32 value in range [0, max).

fn (WyRandRNG) f64 #

fn (mut rng WyRandRNG) f64() f64

f64 returns a pseudorandom f64 value in range [0, 1).

fn (WyRandRNG) f64_in_range #

fn (mut rng WyRandRNG) f64_in_range(min f64, max f64) f64

i64_in_range returns a pseudorandom i64 in range [min, max).

fn (WyRandRNG) f64n #

fn (mut rng WyRandRNG) f64n(max f64) f64

f64n returns a pseudorandom f64 value in range [0, max).

fn (WyRandRNG) free #

unsafe
fn (mut rng WyRandRNG) free()

free should be called when the generator is no longer needed

fn (WyRandRNG) i64 #

fn (mut rng WyRandRNG) i64() i64

i64 returns a (possibly negative) pseudorandom 64-bit i64.

fn (WyRandRNG) i64_in_range #

fn (mut rng WyRandRNG) i64_in_range(min i64, max i64) i64

i64_in_range returns a pseudorandom i64 in range [min, max).

fn (WyRandRNG) i64n #

fn (mut rng WyRandRNG) i64n(max i64) i64

i64n returns a pseudorandom int that lies in [0, max).

fn (WyRandRNG) int #

fn (mut rng WyRandRNG) int() int

int returns a (possibly negative) pseudorandom 32-bit int.

fn (WyRandRNG) int31 #

fn (mut rng WyRandRNG) int31() int

int31 returns a positive pseudorandom 31-bit int.

fn (WyRandRNG) int63 #

fn (mut rng WyRandRNG) int63() i64

int63 returns a positive pseudorandom 63-bit i64.

fn (WyRandRNG) int_in_range #

fn (mut rng WyRandRNG) int_in_range(min int, max int) int

int_in_range returns a pseudorandom int in range [min, max).

fn (WyRandRNG) intn #

fn (mut rng WyRandRNG) intn(max int) int

intn returns a pseudorandom int in range [0, max).

fn (WyRandRNG) seed #

fn (mut rng WyRandRNG) seed(seed_data []u32)

seed sets the seed, needs only two u32s in little-endian format as [lower, higher].

fn (WyRandRNG) u32 #

fn (mut rng WyRandRNG) u32() u32

u32 updates the PRNG state and returns the next pseudorandom u32.

fn (WyRandRNG) u32_in_range #

fn (mut rng WyRandRNG) u32_in_range(min u32, max u32) u32

u32n returns a pseudorandom u32 value that is guaranteed to be in range [min, max).

fn (WyRandRNG) u32n #

fn (mut rng WyRandRNG) u32n(max u32) u32

u32n returns a pseudorandom u32 less than max.

fn (WyRandRNG) u64 #

fn (mut rng WyRandRNG) u64() u64

u64 updates the PRNG state and returns the next pseudorandom u64.

fn (WyRandRNG) u64_in_range #

fn (mut rng WyRandRNG) u64_in_range(min u64, max u64) u64

u64n returns a pseudorandom u64 value that is guaranteed to be in range [min, max).

fn (WyRandRNG) u64n #

fn (mut rng WyRandRNG) u64n(max u64) u64

u64n returns a pseudorandom u64 less than max.