ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::utility::random::UniformIntGenerator< T > Class Template Reference

#include <Random.h>

Public Member Functions

 UniformIntGenerator (const T low, const T high)
 
operator() ()
 Call this to generate a uniformly distributed integer. More...
 

Protected Attributes

std::uniform_int_distribution< T > distribution_
 

Detailed Description

template<typename T>
class cloudViewer::utility::random::UniformIntGenerator< T >

Generate uniformly distributed random integers in [low, high]. This class is globally seeded by utility::random::Seed(). This class is a wrapper around std::uniform_int_distribution.

Example:

// Globally seed cloudViewer. This will affect all random functions.
// Generate a random int in [0, 100].
utility::random::UniformIntGenerator<int> gen(0, 100);
for (size_t i = 0; i < 10; i++) {
std::cout << gen() << std::endl;
}
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
void Seed(const int seed)
Set CloudViewer global random seed.
Definition: Random.cpp:53

Definition at line 66 of file Random.h.

Constructor & Destructor Documentation

◆ UniformIntGenerator()

template<typename T >
cloudViewer::utility::random::UniformIntGenerator< T >::UniformIntGenerator ( const T  low,
const T  high 
)
inline

Generate uniformly distributed random integer from [low, low + 1, ... high].

Parameters
lowThe lower bound (inclusive).
highThe upper bound (inclusive). high must be >= low.

Definition at line 73 of file Random.h.

References LogError.

Member Function Documentation

◆ operator()()

template<typename T >
T cloudViewer::utility::random::UniformIntGenerator< T >::operator() ( )
inline

Call this to generate a uniformly distributed integer.

Definition at line 85 of file Random.h.

References cloudViewer::utility::random::UniformIntGenerator< T >::distribution_, cloudViewer::utility::random::GetEngine(), and cloudViewer::utility::random::GetMutex().

Member Data Documentation

◆ distribution_

template<typename T >
std::uniform_int_distribution<T> cloudViewer::utility::random::UniformIntGenerator< T >::distribution_
protected

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