alaCarte Maps
Renderer for OpenStreetMap tiles
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
random.cpp
Go to the documentation of this file.
1
2
#include "
utils/random.hpp
"
3
4
#include <ctime>
5
6
7
8
Random
Random::m_RandomGenerator
;
9
10
11
Random::Random
()
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
27
Random::~Random
()
28
{
29
}
30
31
32
void
Random::next
()
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::Random
Random()
Definition:
random.cpp:11
Random
Definition:
random.hpp:8
Random::m_RandomGenerator
static Random m_RandomGenerator
Definition:
random.hpp:37
random.hpp
Random::~Random
~Random()
Definition:
random.cpp:27
Random::m_RandomSeed
unsigned long m_RandomSeed
Definition:
random.hpp:38
Random::next
void next()
Definition:
random.cpp:32
src
utils
random.cpp
Generated on Thu May 24 2018 16:14:00 for alaCarte Maps by
1.8.11