alaCarte Maps
Renderer for OpenStreetMap tiles
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
random.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef _RANDOM_HPP
3
#define _RANDOM_HPP
4
5
#include "
settings.hpp
"
6
7
8
class
Random
9
{
10
public
:
11
Random
();
12
Random
(
unsigned
long
_init);
13
~Random
();
14
15
void
next
();
16
17
template
<
typename
T>
18
inline
T
rand
();
19
inline
int
rand
();
20
template
<
typename
T>
21
inline
T
rand
(T _max);
22
template
<
typename
T>
23
inline
T
rand
(T _min, T _max);
24
25
26
inline
static
void
Next
();
27
28
template
<
typename
T>
29
inline
static
T
Rand
();
30
inline
static
int
Rand
();
31
template
<
typename
T>
32
inline
static
T
Rand
(T _max);
33
template
<
typename
T>
34
inline
static
T
Rand
(T _min, T _max);
35
36
private
:
37
static
Random
m_RandomGenerator
;
38
unsigned
long
m_RandomSeed
;
39
};
40
41
42
template
<
typename
T>
43
inline
T
Random::rand
()
44
{
45
next
();
46
return
static_cast<
T
>
(
m_RandomSeed
);
47
}
48
49
inline
int
Random::rand
()
50
{
51
return
rand<int>();
52
}
53
54
template
<
typename
T>
55
inline
T
Random::rand
(T _max)
56
{
57
return
rand
(static_cast<T>(0), _max);
58
}
59
60
template
<
typename
T>
61
inline
T
Random::rand
(T _min, T _max)
62
{
63
return
static_cast<
T
>
(_min + ((rand<int>() - 1) / 2147483646.0) * (_max - _min));
64
}
65
66
67
68
inline
void
Random::Next
()
69
{
70
m_RandomGenerator
.
next
();
71
}
72
73
template
<
typename
T>
74
inline
T
Random::Rand
()
75
{
76
return
m_RandomGenerator
.
rand
<T>();
77
}
78
79
inline
int
Random::Rand
()
80
{
81
return
m_RandomGenerator
.
rand
<
int
>();
82
}
83
84
template
<
typename
T>
85
inline
T
Random::Rand
(T _max)
86
{
87
return
m_RandomGenerator
.
rand
(_max);
88
}
89
90
template
<
typename
T>
91
inline
T
Random::Rand
(T _min, T _max)
92
{
93
return
m_RandomGenerator
.
rand
(_min, _max);
94
}
95
96
97
#endif
Random::Random
Random()
Definition:
random.cpp:11
Random
Definition:
random.hpp:8
Random::Next
static void Next()
Definition:
random.hpp:68
settings.hpp
Random::Rand
static T Rand()
Definition:
random.hpp:74
Random::rand
T rand()
Definition:
random.hpp:43
Random::m_RandomGenerator
static Random m_RandomGenerator
Definition:
random.hpp:37
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
include
utils
random.hpp
Generated on Thu May 24 2018 16:14:00 for alaCarte Maps by
1.8.11