00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _PRANDOM
00032 #define _PRANDOM
00033
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039 #ifndef _PTLIB_H
00040 #include <ptlib.h>
00041 #endif
00042
00059 class PRandom
00060 {
00061 public:
00066 PRandom();
00067
00072 PRandom(
00073 DWORD seed
00074 );
00075
00078 void SetSeed(
00079 DWORD seed
00080 );
00081
00086 unsigned Generate();
00087
00092 unsigned Generate(unsigned maximum);
00093
00098 unsigned Generate(unsigned minimum, unsigned maximum);
00099
00105 inline operator unsigned() { return Generate(); }
00106
00107
00112 static unsigned Number();
00113
00116 static unsigned Number(unsigned maximum);
00117
00120 static unsigned Number(unsigned minimum, unsigned maximum);
00121
00122 protected:
00123 enum {
00124 RandBits = 8,
00125 RandSize = 1<<RandBits
00126 };
00127
00128 DWORD randcnt;
00129 DWORD randrsl[RandSize];
00130 DWORD randmem[RandSize];
00131 DWORD randa;
00132 DWORD randb;
00133 DWORD randc;
00134 };
00135
00136
00137 #endif // _PRANDOM
00138
00139
00140