cppcore
A small, portable C++ core library
Loading...
Searching...
No Matches
cppcore::RandomGenerator Class Reference

This class is used to wrap different random number generators. More...

#include <RandomGenerator.h>

Public Types

enum class  GeneratorType { Standard , MersenneTwister }
 This enum describes the requested random generator. More...

Public Member Functions

 RandomGenerator (GeneratorType type=GeneratorType::Standard) noexcept
 The class constructor.
 ~RandomGenerator ()=default
 The class destructor.
int get (int lower, int upper)
 Gets a new random number.
 RandomGenerator (const RandomGenerator &)=delete
RandomGenerator & operator= (const RandomGenerator &)=delete

Detailed Description

This class is used to wrap different random number generators.

Definition at line 37 of file RandomGenerator.h.

Member Enumeration Documentation

◆ GeneratorType

This enum describes the requested random generator.

Enumerator
Standard 

The default c+++ generator.

MersenneTwister 

The MersenneTwister algorithm.

Definition at line 40 of file RandomGenerator.h.

Constructor & Destructor Documentation

◆ RandomGenerator() [1/2]

cppcore::RandomGenerator::RandomGenerator ( GeneratorType type = GeneratorType::Standard)
noexcept

The class constructor.

Parameters
type[in] The requested generator.

Definition at line 93 of file RandomGenerator.cpp.

Referenced by operator=(), and RandomGenerator().

◆ ~RandomGenerator()

cppcore::RandomGenerator::~RandomGenerator ( )
default

The class destructor.

References get().

◆ RandomGenerator() [2/2]

cppcore::RandomGenerator::RandomGenerator ( const RandomGenerator & )
delete

References RandomGenerator().

Member Function Documentation

◆ get()

int cppcore::RandomGenerator::get ( int lower,
int upper )

Gets a new random number.

Parameters
lower[in] The lower bound.
upper[in] The upper bound.
Returns
A new random number.

Definition at line 98 of file RandomGenerator.cpp.

References cppcore::mersenne_twister(), MersenneTwister, and Standard.

Referenced by ~RandomGenerator().

◆ operator=()

RandomGenerator & cppcore::RandomGenerator::operator= ( const RandomGenerator & )
delete

References RandomGenerator().


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