A FloatGenerator which returns a uniformly distributed value within a defined range.
More...
#include <RandGenerator.h>
|
float | _min |
| The lower end of the valid range.
|
|
float | _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.
|
|
A FloatGenerator which returns a uniformly distributed value within a defined range.
Menge::Math::UniformFloatGenerator::UniformFloatGenerator |
( |
float |
minVal, |
|
|
float |
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. |
Copy constructor.
The copy is not a perfect copy - the seed value in the new float generator is NOT the same as the source.
- Parameters
-
Create a copy of itself.
- 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::FloatGenerator.
float Menge::Math::UniformFloatGenerator::getMax |
( |
| ) |
const |
|
inline |
Reports the upper end of the valid range.
- Returns
- The upper end of the valid range.
float Menge::Math::UniformFloatGenerator::getMin |
( |
| ) |
const |
|
inline |
Reports the lower end of the valid range.
- Returns
- The lower end of the valid range.
float Menge::Math::UniformFloatGenerator::getSize |
( |
| ) |
const |
|
inline |
Reports the size of the interval.
- Returns
- The size of the interval.
float Menge::Math::UniformFloatGenerator::getValue |
( |
| ) |
const |
|
virtual |
Return a value based on the float generation rules.
- Returns
- A clamped, uniformly-distributed float value.
Implements Menge::Math::FloatGenerator.
float Menge::Math::UniformFloatGenerator::getValueConcurrent |
( |
| ) |
const |
|
virtual |
Return a value based on the float generation rules - performed in a thread-safe manner.
This is the basic functionality that must be overwridden by derived classes.
- Returns
- A float value.
Implements Menge::Math::FloatGenerator.
void Menge::Math::UniformFloatGenerator::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::FloatGenerator.
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