Project

General

Profile

BitmapToolkit Scol plugin
DUtils::Random::UnrepeatedRandomizer Class Reference

Provides pseudo-random numbers with no repetitions. More...

#include <Random.h>

Public Member Functions

 UnrepeatedRandomizer (int min, int max)
 
 ~UnrepeatedRandomizer ()
 
 UnrepeatedRandomizer (const UnrepeatedRandomizer &rnd)
 
UnrepeatedRandomizeroperator= (const UnrepeatedRandomizer &rnd)
 
int get ()
 
bool empty () const
 
unsigned int left () const
 
void reset ()
 

Protected Member Functions

void createValues ()
 

Protected Attributes

int m_min
 Min of range of values.
 
int m_max
 Max of range of values.
 
std::vector< int > m_values
 Available values.
 

Detailed Description

Provides pseudo-random numbers with no repetitions.

Definition at line 112 of file Random.h.

Constructor & Destructor Documentation

◆ UnrepeatedRandomizer() [1/2]

DUtils::Random::UnrepeatedRandomizer::UnrepeatedRandomizer ( int  min,
int  max 
)

Creates a randomizer that returns numbers in the range [min, max]

Parameters
min
max

Definition at line 55 of file Random.cpp.

◆ ~UnrepeatedRandomizer()

DUtils::Random::UnrepeatedRandomizer::~UnrepeatedRandomizer ( )
inline

Definition at line 122 of file Random.h.

◆ UnrepeatedRandomizer() [2/2]

DUtils::Random::UnrepeatedRandomizer::UnrepeatedRandomizer ( const UnrepeatedRandomizer rnd)

Copies a randomizer

Parameters
rnd

Definition at line 73 of file Random.cpp.

Member Function Documentation

◆ createValues()

void DUtils::Random::UnrepeatedRandomizer::createValues ( )
protected

Creates the vector with available values

Definition at line 97 of file Random.cpp.

◆ empty()

bool DUtils::Random::UnrepeatedRandomizer::empty ( ) const
inline

Returns whether all the possible values between min and max were already given. If get() is called when empty() is true, the behaviour is the same than after creating the randomizer

Returns
true iff all the values were returned

Definition at line 149 of file Random.h.

◆ get()

int DUtils::Random::UnrepeatedRandomizer::get ( )

Returns a random number not given before. If all the possible values were already given, the process starts again

Returns
unrepeated random number

Definition at line 81 of file Random.cpp.

◆ left()

unsigned int DUtils::Random::UnrepeatedRandomizer::left ( ) const
inline

Returns the number of values still to be returned

Returns
amount of values to return

Definition at line 155 of file Random.h.

◆ operator=()

DUtils::Random::UnrepeatedRandomizer & DUtils::Random::UnrepeatedRandomizer::operator= ( const UnrepeatedRandomizer rnd)

Copies a randomizer

Parameters
rnd

Definition at line 115 of file Random.cpp.

◆ reset()

void DUtils::Random::UnrepeatedRandomizer::reset ( )

Resets the randomizer as it were just created

Definition at line 107 of file Random.cpp.

Member Data Documentation

◆ m_max

int DUtils::Random::UnrepeatedRandomizer::m_max
protected

Max of range of values.

Definition at line 174 of file Random.h.

◆ m_min

int DUtils::Random::UnrepeatedRandomizer::m_min
protected

Min of range of values.

Definition at line 172 of file Random.h.

◆ m_values

std::vector<int> DUtils::Random::UnrepeatedRandomizer::m_values
protected

Available values.

Definition at line 177 of file Random.h.


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