PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
random.h
Go to the documentation of this file.
1 /*
2 * random.h
3 *
4 * ISAAC random number generator by Bob Jenkins.
5 *
6 * Portable Windows Library
7 *
8 * Copyright (c) 1993-2000 Equivalence Pty. Ltd.
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * The Original Code is Portable Windows Library.
21 *
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23 *
24 * Contributor(s): ______________________________________.
25 *
26 * $Revision: 21788 $
27 * $Author: rjongbloed $
28 * $Date: 2008-12-12 16:42:13 +1100 (Fri, 12 Dec 2008) $
29 */
30
31 #ifndef PTLIB_RANDOM_H
32 #define PTLIB_RANDOM_H
33
34
35 #ifdef P_USE_PRAGMA
36 #pragma interface
37 #endif
38
39
56 class PRandom
57 {
58 public:
63 PRandom();
64
69 PRandom(
70 DWORD seed
71 );
72
75 void SetSeed(
76 DWORD seed
77 );
78
83 unsigned Generate();
84
89 unsigned Generate(unsigned maximum);
90
95 unsigned Generate(unsigned minimum, unsigned maximum);
96
102 inline operator unsigned() { return Generate(); }
103
104
109 static unsigned Number();
110
113 static unsigned Number(unsigned maximum);
114
117 static unsigned Number(unsigned minimum, unsigned maximum);
118
119 protected:
120 enum {
121 RandBits = 8,
122 RandSize = 1<<RandBits
123 };
124
125 DWORD randcnt;
126 DWORD randrsl[RandSize];
127 DWORD randmem[RandSize];
128 DWORD randa;
129 DWORD randb;
130 DWORD randc;
131 };
132
133
134 #endif // PTLIB_RANDOM_H
135
136
137 // End Of File ///////////////////////////////////////////////////////////////