libcommonc++  0.7
Random Class Reference

A random number generator. More...

#include <Random.h++>

Public Member Functions

 Random ()
 Construct a new random number generator with a default seed which is based on a combination of the current thread ID, process ID, and system time. More...
 
 Random (uint32_t seed)
 Construct a new random number generator with the given seed. More...
 
 ~Random ()
 Destructor. More...
 
uint32_t nextInt (uint32_t range)
 Generate a random integer. More...
 
double nextDouble ()
 Generate a random double value. More...
 
bool getBytes (byte_t *buf, size_t len)
 Fill a byte buffer with random bytes. More...
 

Detailed Description

A random number generator.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ Random() [1/2]

Random ( )

Construct a new random number generator with a default seed which is based on a combination of the current thread ID, process ID, and system time.

◆ Random() [2/2]

Random ( uint32_t  seed)

Construct a new random number generator with the given seed.

◆ ~Random()

~Random ( )

Destructor.

Member Function Documentation

◆ getBytes()

bool getBytes ( byte_t buf,
size_t  len 
)

Fill a byte buffer with random bytes.

Parameters
bufThe buffer to fill.
lenThe length of the buffer.
Returns
true on success, false otherwise.

◆ nextDouble()

double nextDouble ( )

Generate a random double value.

Returns
A double in the range [0.0, 1.0).

◆ nextInt()

uint32_t nextInt ( uint32_t  range)

Generate a random integer.

Parameters
rangeThe desired range of the value to be returned.
Returns
An integer in the range [0, range).

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