KSquare Utilities
RandomNumGenerator.h
Go to the documentation of this file.
1 /* RandomNumGenerator.h -- Class that represents one Random Number Generator.
2  * Copyright (C) 1994-2014 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _KKU_RANDOMNUMGENERATOR_
6 #define _KKU_RANDOMNUMGENERATOR_
7 
8 #include "KKBaseTypes.h"
9 
10 namespace KKB
11 {
12  /**
13  *@brief Represents one single random number generator.
14  *@details Rather than using the two global functions "lrand48" and "srand48" you can create an
15  * instance of this class that will provide the random sequence. The advantage is that
16  * you can control who has access to this sequence. That is you do not need to worry that
17  * some other code that you are calling is not also getting numbers from this sequence.
18  * This will allow you to guarantee the same sequence of numbers for the same seed.
19  */
21  {
22  public:
24  RandomNumGenerator (long _seed);
25 
27 
28  long Next ();
29 
30 
31  private:
32  kkint64 _lrand48_sequence;
33 
34  static const kkint64 a;
35  static const kkint64 c;
36  static const kkint64 m;
37  static const kkint64 mask;
38  }; /* RandomNumGenerator */
39 }
40 
41 #endif
__int64 kkint64
Definition: KKBaseTypes.h:90
KKTHread * KKTHreadPtr
Represents one single random number generator.