Maze Builder Docs 8.8.13
Loading...
Searching...
No Matches
mazes::randomizer Class Reference

Provides random-number generating capabilities. More...

#include <randomizer.h>

Public Member Functions

 randomizer ()
 Default constructor.
 ~randomizer ()
 Destructor.
 randomizer (const randomizer &other)
 Copy constructor.
randomizer & operator= (const randomizer &other)
 Copy assignment operator.
 randomizer (randomizer &&other) noexcept
 Move constructor.
randomizer & operator= (randomizer &&other) noexcept
 Move assignment operator.
int get_int (int low=0, int high=1) const noexcept
 Generates a random integer within a specified range.
std::vector< int > sample_int_n (int low=0, int high=1, int n=1) const
 Samples n integers (with replacement) from a uniform distribution over [low, high].
std::vector< float > sample_float_n (float low=0.0f, float high=1.0f, int n=1) const
 Samples n floats from a uniform distribution over [low, high).
float get_float (float low=0.0f, float high=1.0f) const noexcept
 Generates a random float within a specified range.
void seed (unsigned long long seed=0) const noexcept
 Seeds the random number generator with the given seed value.
void seed (std::string_view sv) const noexcept
 Seeds the random number generator with a string view.
int operator() (const int low, const int high) const noexcept
 Gets a random integer within a specified range.

Detailed Description

Provides random-number generating capabilities.

This class provides methods for generating random numbers

Constructor & Destructor Documentation

◆ randomizer() [1/2]

mazes::randomizer::randomizer ( const randomizer & other)

Copy constructor.

Parameters
otherThe randomizer object to copy from

◆ randomizer() [2/2]

mazes::randomizer::randomizer ( randomizer && other)
noexcept

Move constructor.

Parameters
otherThe randomizer object to move from

Member Function Documentation

◆ get_float()

float mazes::randomizer::get_float ( float low = 0.0f,
float high = 1.0f ) const
nodiscardnoexcept

Generates a random float within a specified range.

Parameters
lowThe lower bound of the float (inclusive).
highThe upper bound of the float (inclusive).
Returns
A random float between the specified range [low, high].

◆ get_int()

int mazes::randomizer::get_int ( int low = 0,
int high = 1 ) const
noexcept

Generates a random integer within a specified range.

Parameters
lowThe lower bound of the integer (inclusive).
highThe upper bound of the integer (inclusive).
Returns
A random integer between the specified range [low, high].

◆ operator()()

int mazes::randomizer::operator() ( const int low,
const int high ) const
inlinenoexcept

Gets a random integer within a specified range.

Parameters
lowThe lower bound of the integer (inclusive).
highThe upper bound of the integer (inclusive).
Returns
A random integer within the specified range.

◆ operator=() [1/2]

randomizer & mazes::randomizer::operator= ( const randomizer & other)

Copy assignment operator.

Parameters
otherThe randomizer object to copy from
Returns
Reference to the current object

◆ operator=() [2/2]

randomizer & mazes::randomizer::operator= ( randomizer && other)
noexcept

Move assignment operator.

Parameters
otherThe randomizer object to move from
Returns
Reference to the current object

◆ sample_float_n()

std::vector< float > mazes::randomizer::sample_float_n ( float low = 0.0f,
float high = 1.0f,
int n = 1 ) const
nodiscard

Samples n floats from a uniform distribution over [low, high).

Parameters
lowThe lower bound (inclusive).
highThe upper bound.
nThe number of samples to draw
Returns
n samples, or an empty vector if low > high or n <= 0

◆ sample_int_n()

std::vector< int > mazes::randomizer::sample_int_n ( int low = 0,
int high = 1,
int n = 1 ) const
nodiscard

Samples n integers (with replacement) from a uniform distribution over [low, high].

Parameters
lowThe lower bound (inclusive).
highThe upper bound (inclusive).
nThe number of samples to draw
Returns
n samples, or an empty vector if low > high or n <= 0

◆ seed() [1/2]

void mazes::randomizer::seed ( std::string_view sv) const
noexcept

Seeds the random number generator with a string view.

Parameters
svThe string view to initialize the random number generator.

◆ seed() [2/2]

void mazes::randomizer::seed ( unsigned long long seed = 0) const
noexcept

Seeds the random number generator with the given seed value.

Parameters
seedThe seed value to initialize the random number generator.

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