ge211
Random Class Reference

Detailed Description

A pseudo-random number generator.

This class has member functions for generating random numbers.

Definition at line 63 of file ge211_random.h.

Public Member Functions

template<class T >
up_to (T max)
 Returns a random T between 0 (inclusive) and max (exclusive). More...
 
template<class T >
between (T min, T max)
 Returns a random T between min and max. More...
 
bool random_bool (double ptrue=0.5)
 Returns a random bool that is true with probability ptrue. More...
 

Member Function Documentation

◆ between()

T between ( min,
max 
)
inline

Returns a random T between min and max.

The right bound is inclusive for integral types but exclusive for floating point types. The left bound is always inclusive.

Example:

int roll_the_die(Random& random)
{
return random.between(1, 6);
}

Definition at line 95 of file ge211_random.h.

◆ random_bool()

bool random_bool ( double  ptrue = 0.5)

Returns a random bool that is true with probability ptrue.

Definition at line 22 of file ge211_random.cpp.

◆ up_to()

T up_to ( max)
inline

Returns a random T between 0 (inclusive) and max (exclusive).

Example:

int roll_the_die(Random& random)
{
return random.up_to(6) + 1;
}

Definition at line 77 of file ge211_random.h.


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