00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_RANDOM_H_
00019 #define _DECAF_UTIL_RANDOM_H_
00020
00021 #include <decaf/lang/exceptions/IllegalArgumentException.h>
00022 #include <decaf/util/Config.h>
00023 #include <vector>
00024 #include <cmath>
00025
00026 namespace decaf{
00027 namespace util{
00028
00037 class DECAF_API Random {
00038 private:
00039
00040 static unsigned long long multiplier;
00041
00045 bool haveNextNextGaussian;
00046
00050 unsigned long long seed;
00051
00055 double nextNextGaussian;
00056
00057 public:
00058
00065 Random();
00066
00076 Random(unsigned long long seed);
00077
00078 virtual ~Random();
00079
00080 public:
00081
00089 bool nextBoolean();
00090
00099 double nextDouble();
00100
00109 float nextFloat();
00110
00124 double nextGaussian();
00125
00135 int nextInt();
00136
00149 int nextInt(int n);
00150
00161 long long nextLong();
00162
00163 public:
00164
00173 virtual void nextBytes(std::vector<unsigned char>& buf);
00174
00186 virtual void nextBytes(unsigned char* buf, int size);
00187
00200 virtual void setSeed(unsigned long long seed);
00201
00202 protected:
00203
00222 virtual int next(int bits);
00223
00224 };
00225
00226 }}
00227
00228 #endif