CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Random Class Reference

Pseudo-random number generator. More...

#include <cc/Random>

Public Member Functions

 Random (uint32_t seed=0)
 Create a new random number generator.
 
uint32_t get ()
 Generate another random number.
 
uint32_t get (uint32_t a, uint32_t b)
 Get another random number in range [a, b].
 
uint32_t operator() ()
 Generate another random number.
 
uint32_t operator() (uint32_t a, uint32_t b)
 Get another random number in range [a, b].
 
template<class Container >
void shuffle (Container &container)
 Randomly shuffle items in container.
 

Detailed Description

Pseudo-random number generator.

The Random class provides a simple and fast pseudo-random number generator.

Constructor & Destructor Documentation

◆ Random()

Random ( uint32_t seed = 0)
explicit

Create a new random number generator.

Parameters
seedSeed number

Member Function Documentation

◆ get() [1/2]

uint32_t get ( )

Generate another random number.

◆ get() [2/2]

uint32_t get ( uint32_t a,
uint32_t b )

Get another random number in range [a, b].

◆ operator()() [1/2]

uint32_t operator() ( )

Generate another random number.

◆ operator()() [2/2]

uint32_t operator() ( uint32_t a,
uint32_t b )

Get another random number in range [a, b].

◆ shuffle()

template<class Container >
void shuffle ( Container & container)

Randomly shuffle items in container.