Blackcomb  prealpha
Engine-ish
Public Member Functions | List of all members
blackcomb::misc::RNG Class Reference

A wrapper for C++'s random number generator featuring a very original interface. More...

#include <RNG.h>

Public Member Functions

 RNG (unsigned long seed)
 
template<typename T >
randRange (T min, T max)
 Generates a random number in a range from min to max, inclusive. More...
 
template<typename T >
random ()
 Generates a random real number from zero to one, inclusive. More...
 
template<typename T >
randInt (T min, T max)
 Generates a random integer in a range from min to max, inclusive. More...
 
template<typename T >
choice (std::vector< T > vec)
 Selects a random element from a vector.
 
void setSeed (unsigned long seed)
 Sets the random number generator's seed.
 

Detailed Description

A wrapper for C++'s random number generator featuring a very original interface.

Member Function Documentation

◆ randInt()

template<typename T >
T blackcomb::misc::RNG::randInt ( min,
max 
)

Generates a random integer in a range from min to max, inclusive.

Template Parameters
TThe type of the number, which must be an integer (short, int, long, long long, and unsigned variants). For floats, see randRange type.

◆ random()

template<typename T >
T blackcomb::misc::RNG::random ( )

Generates a random real number from zero to one, inclusive.

Template Parameters
TThey type of the number, which must be float, double, or long double (for integer, use choice<int>({0, 1})).

◆ randRange()

template<typename T >
T blackcomb::misc::RNG::randRange ( min,
max 
)

Generates a random number in a range from min to max, inclusive.

Template Parameters
TThe type of the number, either float, double, or long double (for int, see randInt).

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