Open3D (C++ API)  0.18.0+5c982c7
Public Member Functions | Protected Attributes
open3d::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 open3d::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 Open3D. 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;
}
void Seed(const int seed)
Set Open3D global random seed.
Definition: Random.cpp:53

Constructor & Destructor Documentation

◆ UniformIntGenerator()

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

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

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

Member Function Documentation

◆ operator()()

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

Call this to generate a uniformly distributed integer.

Field Documentation

◆ distribution_

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

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