An IntGenerator which returns a uniformly distributed value within a defined range.
More...
#include <RandGenerator.h>
|
int | _min |
| The lower end of the valid range.
|
|
int | _size |
| The size of the valid range.
|
|
int | _seed |
| A seed for the random number generator.
|
|
SimpleLock | _lock |
| The lock for guaranteeing threadsafe random number generation.
|
|
An IntGenerator which returns a uniformly distributed value within a defined range.
Menge::Math::UniformIntGenerator::UniformIntGenerator |
( |
int |
minVal, |
|
|
int |
maxVal, |
|
|
int |
seed = 0 |
|
) |
| |
Constructor.
The value will lie within the range [minVal, maxVal]. All values in that range have equal probability of being selected.
- Parameters
-
minVal | The lower end of the valid range. |
maxVal | The upper end of the valid range. |
seed | If the seed is zero, the global seed will be used otherwise the particular seed will be used. |
IntGenerator * Menge::Math::UniformIntGenerator::copy |
( |
| ) |
const |
|
virtual |
Create a copy of itself.
This is the basic functionality that must be overwridden by derived classes.
- Returns
- A pointer to a new generator which is a copy of this one. The caller of this function is responsible for freeing up the memory for the copy.
Implements Menge::Math::IntGenerator.
int Menge::Math::UniformIntGenerator::getValue |
( |
| ) |
const |
|
virtual |
Return a value based on the integer generation rules.
- Returns
- A uniformly distributed integer value.
Implements Menge::Math::IntGenerator.
int Menge::Math::UniformIntGenerator::getValueConcurrent |
( |
| ) |
const |
|
virtual |
Return a value based on the integer generation rules - performed in a thread-safe manner.
This is the basic functionality that must be overwridden by derived classes.
- Returns
- A integer value.
Implements Menge::Math::IntGenerator.
void Menge::Math::UniformIntGenerator::print |
( |
Logger & |
out | ) |
const |
|
virtual |
Function for converting the generator to a string on a output stream.
- Parameters
-
out | The output stream to write the string representation to. |
Implements Menge::Math::IntGenerator.
void Menge::Math::UniformIntGenerator::setRange |
( |
int |
minVal, |
|
|
int |
maxVal |
|
) |
| |
|
inline |
Set the selection range.
- Parameters
-
minVal | The lower end of the valid range. |
maxVal | The upper end of the valid range. |
Friend function for writing string representation to an output stream.
- Parameters
-
out | The output stream. |
gen | An instance of the generator to represent as a string. |
- Returns
- Reference to the input output stream.
The documentation for this class was generated from the following files:
- src/menge/MengeCore/Math/RandGenerator.h
- src/menge/MengeCore/Math/RandGenerator.cpp