alaCarte Maps
Renderer for OpenStreetMap tiles
random.cpp
Go to the documentation of this file.
1 
2 #include "utils/random.hpp"
3 
4 #include <ctime>
5 
6 
7 
9 
10 
12  : m_RandomSeed(0)
13 {
14  m_RandomSeed = (unsigned int)clock();
15 
16  if(m_RandomSeed == 0)
17  m_RandomSeed = 1;
18 
19  next();
20 }
21 
22 Random::Random(unsigned long _init)
23  : m_RandomSeed(_init)
24 {
25 }
26 
28 {
29 }
30 
31 
33 {
34  // optimized standard minimal
35  long tmp0 = 16807L * (m_RandomSeed & 0xFFFFL);
36  long tmp1 = 16807L * (m_RandomSeed >> 16);
37  long tmp2 = (tmp0 >> 16) + tmp1;
38  tmp0 = ((tmp0 & 0xFFFF)|((tmp2 & 0x7FFF) << 16)) + (tmp2 >> 15);
39 
40  // correction of the error
41  if ((tmp0 & 0x80000000L) != 0)
42  tmp0 = (tmp0 + 1) & 0x7FFFFFFFL;
43 
44  m_RandomSeed = tmp0;
45 }
Random()
Definition: random.cpp:11
Definition: random.hpp:8
static Random m_RandomGenerator
Definition: random.hpp:37
~Random()
Definition: random.cpp:27
unsigned long m_RandomSeed
Definition: random.hpp:38
void next()
Definition: random.cpp:32