aboutsummaryrefslogtreecommitdiffstats
path: root/util/random/random.h
blob: d5c99de95b79a71c96f378eaccbbb3f6c98b2d72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
 
/* 
 * thread-safe random number generator. 
 * 
 * specialized for: 
 *  all unsigned types (return value in range [0, MAX_VALUE_FOR_TYPE]) 
 *  bool
 *  long double (return value in range [0, 1)) 
 *  double (return value in range [0, 1)) 
 *  float (return value in range [0, 1)) 
 */ 
template <class T> 
T RandomNumber(); 
 
/*
 * returns value in range [0, max)
 */
template <class T>
T RandomNumber(T max);

/*
 * Re-initialize random state - useful after forking in multi-process programs.
 */
void ResetRandomState();

/*
 * Set random SEED
 */
void SetRandomSeed(int seed);