#include <Random.hpp>
Public Methods | |
| Random () | |
| Random (const ULONG Size) | |
| Random (const ULONG Size, const ULONG Max) | |
| Random (const ULONG Size, const ULONG Max, const UINT value) | |
| Random (Random &s) | |
| virtual | ~Random () |
| void | init () const |
| ULONG | getMaximum () const |
| UINT | getSeed () const |
| ULONG | getSize () const |
| void | Clear () |
| void | Resize (const ULONG Size) |
| void | Backup () |
| void | Restore () |
| void | Display () |
| void | Randomize () |
| void | Randomize (const uint value) |
| void | Verify (const ULONG spread) |
| void | feed () |
| void | feedUp () |
| void | feedDown () |
| void | feedValue (Elem value) |
| void | feed (BOOL keepBackup) |
| void | feedUp (BOOL keepBackup) |
| void | feedDown (BOOL keepBackup) |
| void | feedValue (BOOL keepBackup, Elem value) |
| Elem | getRnd () |
| Elem | getRnd (const ULONG Max) |
| Elem * | getArray () |
Private Attributes | |
| Elem * | array |
| Elem * | arrayBackup |
| ULONG | maximum |
| uint | seed |
| ULONG | size |
| BOOL | filled |
|
|
Definition at line 9 of file Random.cpp. |
|
|
Definition at line 16 of file Random.cpp. |
|
||||||||||||
|
Definition at line 23 of file Random.cpp. |
|
||||||||||||||||
|
Definition at line 30 of file Random.cpp. |
|
|
|
|
|
Definition at line 52 of file Random.cpp. 00053 {
00054 // Clear();
00055 }
|
|
|
Definition at line 87 of file Random.cpp. |
|
|
Definition at line 57 of file Random.cpp. Referenced by Resize().
|
|
|
Definition at line 263 of file Random.cpp. |
|
|
|
|
|
Definition at line 183 of file Random.cpp. Referenced by Random().
00184 {
00185 // Seed the random-number generator with current time so that
00186 // the numbers will be different every time we run.
00187 seed = (UINT)time( NULL );
00188 init();
00189 }
|
|
|
Definition at line 74 of file Random.cpp. Referenced by Random().
|
|
|
Definition at line 95 of file Random.cpp. |
|
|
Definition at line 240 of file Random.cpp. 00241 {
00242 Elem* nb = new Elem[ spread ];
00243 register size_t i = 0;
00244
00245 for( i = 0; i < size; i++ )
00246 {
00247 array[i] = getRnd();
00248
00249 nb[ array[i] % spread ]++;
00250
00251 printf( " [%6d] ", array[i] );
00252 }
00253
00254 printf("\n\n");
00255
00256 for( i = 0; i < spread; i++ )
00257 {
00258 double s = (double)array[i] / size * 100;
00259 printf( " %6d %.2f \t", array[i], s );
00260 }
00261 }
|
|
|
Definition at line 123 of file Random.cpp. |
|
|
Definition at line 103 of file Random.cpp. 00104 {
00105 feed( false );
00106 }
|
|
|
Definition at line 168 of file Random.cpp. |
|
|
Definition at line 113 of file Random.cpp. 00114 {
00115 feedDown( false );
00116 }
|
|
|
Definition at line 153 of file Random.cpp. |
|
|
Definition at line 108 of file Random.cpp. 00109 {
00110 feedUp( false );
00111 }
|
|
||||||||||||
|
Definition at line 138 of file Random.cpp. |
|
|
Definition at line 118 of file Random.cpp. 00119 {
00120 feedValue( false, value );
00121 }
|
|
|
Definition at line 203 of file Random.cpp. 00204 {
00205 return array;
00206 }
|
|
|
Definition at line 213 of file Random.cpp. 00214 {
00215 return maximum;
00216 }
|
|
|
Definition at line 228 of file Random.cpp. 00229 {
00230 // Get a number of type Elem from a double calculation
00231 // to obtain a wide uniform spread random number
00232 // in the range from 0 to Max.
00233
00234 double r1 = rand();
00235 double r2 = r1 / RAND_MAX * Max;
00236
00237 return ( Elem ) floor( r2 + 0.5 );
00238 }
|
|
|
Definition at line 223 of file Random.cpp. Referenced by Verify(), and feed().
00224 {
00225 return getRnd( maximum );
00226 }
|
|
|
Definition at line 208 of file Random.cpp. 00209 {
00210 return seed;
00211 }
|
|
|
Definition at line 218 of file Random.cpp. 00219 {
00220 return size;
00221 }
|
|
|
Definition at line 198 of file Random.cpp. Referenced by Randomize(), feed(), feedDown(), feedUp(), and feedValue().
00199 {
00200 srand( seed );
00201 }
|
|
|
Definition at line 48 of file Random.hpp. |
|
|
Definition at line 49 of file Random.hpp. |
|
|
Definition at line 53 of file Random.hpp. |
|
|
Definition at line 50 of file Random.hpp. |
|
|
Definition at line 51 of file Random.hpp. |
|
|
Definition at line 52 of file Random.hpp. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001