FreeNOS
Public Member Functions | Static Private Attributes
Randomizer Class Reference

Produces random integers using the Linear congruential generator algorithm. More...

#include <Randomizer.h>

Public Member Functions

void seed (const ulong value)
 Set a value as the current state. More...
 
ulong next ()
 Get next randomized value. More...
 

Static Private Attributes

static const ulong Modulus = 1 << 31
 Used in modulus operation of calculated value. More...
 
static const ulong Multiplier = 1103515245
 Used to multiply calculated value. More...
 
static const ulong Constant = 12345
 Added to calculated value. More...
 
static ulong m_value = 1
 Current randomizer value. More...
 

Detailed Description

Produces random integers using the Linear congruential generator algorithm.

See also
http://en.wikipedia.org/wiki/Linear_congruential_generator

Definition at line 36 of file Randomizer.h.

Member Function Documentation

◆ next()

ulong Randomizer::next ( )

Get next randomized value.

Returns
Random integer value

Definition at line 27 of file Randomizer.cpp.

References Constant, m_value, Modulus, and Multiplier.

Referenced by random(), and UDPSocket::write().

◆ seed()

void Randomizer::seed ( const ulong  value)

Set a value as the current state.

Parameters
valueValue to set

Definition at line 22 of file Randomizer.cpp.

References m_value.

Referenced by setupRandomizer(), and srandom().

Field Documentation

◆ Constant

const ulong Randomizer::Constant = 12345
staticprivate

Added to calculated value.

Definition at line 47 of file Randomizer.h.

Referenced by next().

◆ m_value

ulong Randomizer::m_value = 1
staticprivate

Current randomizer value.

Definition at line 68 of file Randomizer.h.

Referenced by next(), and seed().

◆ Modulus

const ulong Randomizer::Modulus = 1 << 31
staticprivate

Used in modulus operation of calculated value.

Definition at line 41 of file Randomizer.h.

Referenced by next().

◆ Multiplier

const ulong Randomizer::Multiplier = 1103515245
staticprivate

Used to multiply calculated value.

Definition at line 44 of file Randomizer.h.

Referenced by next().


The documentation for this class was generated from the following files: