don't look for win32 directory in a package
[chaz/yoink] / src / Moof / Random.hh
1
2 /*******************************************************************************
3
4 Copyright (c) 2009, Charles McGarvey
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 *******************************************************************************/
28
29 #ifndef _MOOF_RANDOM_HH_
30 #define _MOOF_RANDOM_HH_
31
32 /**
33 * @file Random.hh
34 * Simple pseudo-random number generators.
35 */
36
37
38 namespace Mf {
39
40 /**
41 * Provide the RNG with a seed.
42 * @param theSeed
43 * @return theSeed
44 */
45
46 unsigned setSeed(unsigned theSeed);
47
48 /**
49 * Seed the RNG with the current time. This is good enough in most cases.
50 * @return The seed used.
51 */
52
53 unsigned setSeed();
54
55
56 /**
57 * The most generic generator gets enough random bits to fill the integer type.
58 * @return Random value of maximum domain for type T.
59 */
60
61 template <typename T>
62 T getRandom();
63
64
65 /**
66 * Get a random boolean value.
67 * @return True or false.
68 */
69
70 template <>
71 bool getRandom<bool>();
72
73
74 /**
75 * Get a random integer value with a limited domain.
76 * @param lower Smallest possible value.
77 * @param upper Largest possible value.
78 * @return Integer between lower and upper, inclusive.
79 */
80
81 template <typename T>
82 T getRandom(T lower, T upper);
83
84
85 /**
86 * Get a random float with a limited domain.
87 * @param lower Smallest possible value.
88 * @param upper Largest possible value.
89 * @return Float between lower and upper, inclusive.
90 */
91
92 template <>
93 float getRandom(float lower, float upper);
94
95 /**
96 * Get a random double with a limited domain.
97 * @param lower Smallest possible value.
98 * @param upper Largest possible value.
99 * @return Double between lower and upper, inclusive.
100 */
101
102 template <>
103 double getRandom(double lower, double upper);
104
105 /**
106 * Get a random float with a domain limited to [0.0, 1.0].
107 * @return Float between 0.0 and 1.0, inclusive.
108 */
109
110 template <>
111 float getRandom();
112
113 /**
114 * Get a random double with a domain limited to [0.0, 1.0].
115 * @return Double between 0.0 and 1.0, inclusive.
116 */
117
118 template <>
119 double getRandom();
120
121
122 } // namespace Mf
123
124
125 #endif // _MOOF_RANDOM_HH_
126
127 /** vim: set ts=4 sw=4 tw=80: *************************************************/
128
This page took 0.035386 seconds and 4 git commands to generate.