Skip to content

rand.wyrand #

Constants #

const seed_len = 2

struct WyRandRNG #

struct WyRandRNG {
	state      u64 = seed.time_seed_64()
	bytes_left int
	buffer     u64

WyRandRNG is a RNG based on the WyHash hashing algorithm.

fn (WyRandRNG) block_size #

fn (mut rng WyRandRNG) block_size() int

block_size returns the number of bits that the RNG can produce in a single iteration.

fn (WyRandRNG) free #

fn (mut rng WyRandRNG) free()

free should be called when the generator is no longer needed

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) u16 #

fn (mut rng WyRandRNG) u16() u16

u16 returns a pseudorandom 16bit int in range [0, 2¹⁶).

fn (WyRandRNG) u32 #

fn (mut rng WyRandRNG) u32() u32

u32 returns a pseudorandom 32bit int in range [0, 2³²).

fn (WyRandRNG) u64 #

fn (mut rng WyRandRNG) u64() u64

u64 returns a pseudorandom 64bit int in range [0, 2⁶⁴).

fn (WyRandRNG) u8 #

fn (mut rng WyRandRNG) u8() u8

byte returns a uniformly distributed pseudorandom 8-bit unsigned positive byte.