Yate
Public Member Functions | Static Public Member Functions | List of all members
Random Class Reference

Pseudo random number generator. More...

#include <yateclass.h>

Public Member Functions

 Random (u_int32_t seed=Time::now()&0xffffffff)
 
u_int32_t get () const
 
void set (u_int32_t seed)
 
u_int32_t next ()
 

Static Public Member Functions

static long int random ()
 
static void srandom (unsigned int seed)
 

Detailed Description

Pseudo random number generator.

Implementation of a system independent pseudo random number generator

Constructor & Destructor Documentation

Random ( u_int32_t  seed = Time::now() & 0xffffffff)
inline

Constructor

Parameters
seedNumber to use as initial sequence seed

Member Function Documentation

u_int32_t get ( ) const
inline

Get the latest random number generated

Returns
Last random number generated
u_int32_t next ( )

Advance the pseudo random sequence and return new value

Returns
Next random number in sequence
static long int random ( )
static

Thread safe (and shared) replacement for library ::random()

Returns
Next random number in the global sequence
void set ( u_int32_t  seed)
inline

Set the pseudo random generator to a known state

Parameters
seedNumber to set as current state
static void srandom ( unsigned int  seed)
static

Thread safe (and shared) replacement for library ::srandom()

Parameters
seedNumber to set as seed in the global sequence

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