All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
random.h
Go to the documentation of this file.
/*
* random.h
*
* ISAAC random number generator by Bob Jenkins.
*
* Portable Windows Library
*
* Copyright (c) 1993-2000 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 21788 $
* $Author: rjongbloed $
* $Date: 2008-12-11 23:42:13 -0600 (Thu, 11 Dec 2008) $
*/
#ifndef PTLIB_RANDOM_H
#define PTLIB_RANDOM_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class PRandom
{
public:
PRandom();
PRandom(
DWORD seed
);
void SetSeed(
DWORD seed
);
unsigned Generate();
unsigned Generate(unsigned maximum);
unsigned Generate(unsigned minimum, unsigned maximum);
inline operator unsigned() { return Generate(); }
static unsigned Number();
static unsigned Number(unsigned maximum);
static unsigned Number(unsigned minimum, unsigned maximum);
protected:
enum {
RandBits = 8,
RandSize = 1<<RandBits
};
DWORD randcnt;
DWORD randrsl[RandSize];
DWORD randmem[RandSize];
DWORD randa;
DWORD randb;
DWORD randc;
};
#endif // PTLIB_RANDOM_H
// End Of File ///////////////////////////////////////////////////////////////
PRandom::RandSize
Definition: random.h:122
PRandom::RandBits
I recommend 8 for crypto, 4 for simulations.
Definition: random.h:121
PRandom::PRandom
PRandom()
Construct the random number generator.
PRandom::randc
DWORD randc
Definition: random.h:130
PRandom::SetSeed
void SetSeed(DWORD seed)
Set the seed for the random number generator.
PRandom::Number
static unsigned Number()
Get the next psuedo-random number in sequence.
PRandom::randa
DWORD randa
Definition: random.h:128
PRandom::randmem
DWORD randmem[RandSize]
Definition: random.h:127
PRandom::randcnt
DWORD randcnt
Definition: random.h:125
PRandom::randrsl
DWORD randrsl[RandSize]
Definition: random.h:126
PRandom::randb
DWORD randb
Definition: random.h:129
PRandom
Mersenne Twister random number generator.
Definition: random.h:56
PRandom::Generate
unsigned Generate()
Get the next psuedo-random number in sequence.