PTLib
Version 2.10.4
|
00001 /* 00002 * random.h 00003 * 00004 * ISAAC random number generator by Bob Jenkins. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-2000 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Revision: 21788 $ 00027 * $Author: rjongbloed $ 00028 * $Date: 2008-12-11 23:42:13 -0600 (Thu, 11 Dec 2008) $ 00029 */ 00030 00031 #ifndef PTLIB_RANDOM_H 00032 #define PTLIB_RANDOM_H 00033 00034 00035 #ifdef P_USE_PRAGMA 00036 #pragma interface 00037 #endif 00038 00039 00056 class PRandom 00057 { 00058 public: 00063 PRandom(); 00064 00069 PRandom( 00070 DWORD seed 00071 ); 00072 00075 void SetSeed( 00076 DWORD seed 00077 ); 00078 00083 unsigned Generate(); 00084 00089 unsigned Generate(unsigned maximum); 00090 00095 unsigned Generate(unsigned minimum, unsigned maximum); 00096 00102 inline operator unsigned() { return Generate(); } 00103 00104 00109 static unsigned Number(); 00110 00113 static unsigned Number(unsigned maximum); 00114 00117 static unsigned Number(unsigned minimum, unsigned maximum); 00118 00119 protected: 00120 enum { 00121 RandBits = 8, 00122 RandSize = 1<<RandBits 00123 }; 00124 00125 DWORD randcnt; 00126 DWORD randrsl[RandSize]; 00127 DWORD randmem[RandSize]; 00128 DWORD randa; 00129 DWORD randb; 00130 DWORD randc; 00131 }; 00132 00133 00134 #endif // PTLIB_RANDOM_H 00135 00136 00137 // End Of File ///////////////////////////////////////////////////////////////