activemq-cpp-3.9.5
Random.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _DECAF_UTIL_RANDOM_H_
19#define _DECAF_UTIL_RANDOM_H_
20
22#include <decaf/util/Config.h>
23#include <vector>
24#include <cmath>
25
26namespace decaf{
27namespace util{
28
38 private:
39
40 static unsigned long long multiplier;
41
45 bool haveNextNextGaussian;
46
50 unsigned long long seed;
51
55 double nextNextGaussian;
56
57 public:
58
66
76 Random(unsigned long long seed);
77
78 virtual ~Random();
79
80 public:
81
90
99 double nextDouble();
100
109 float nextFloat();
110
124 double nextGaussian();
125
135 int nextInt();
136
149 int nextInt(int n);
150
161 long long nextLong();
162
163 public: // Virtual Methods
164
173 virtual void nextBytes(std::vector<unsigned char>& buf);
174
186 virtual void nextBytes(unsigned char* buf, int size);
187
200 virtual void setSeed(unsigned long long seed);
201
202 protected: // Virtual method used by all non-virtual methods in Random.
203
222 virtual int next(int bits);
223
224 };
225
226}}
227
228#endif /*_DECAF_UTIL_RANDOM_H_*/
int nextInt(int n)
Returns to the caller a new pseudo-random integer value which is uniformly distributed between 0 (inc...
double nextDouble()
Generates a normally distributed random double number between 0.0 inclusively and 1....
int nextInt()
Generates a uniformly distributed 32-bit int value from the this random number sequence.
double nextGaussian()
Pseudo-randomly generates (approximately) a normally distributed double value with mean 0....
virtual void setSeed(unsigned long long seed)
Modifies the seed using linear congruential formula presented in The Art of Computer Programming,...
virtual int next(int bits)
Answers a pseudo-random uniformly distributed int value of the number of bits specified by the argume...
long long nextLong()
Generates a uniformly distributed 64-bit int value from the this random number sequence.
bool nextBoolean()
Answers the next pseudo-random, uniformly distributed boolean value generated by this generator.
virtual void nextBytes(std::vector< unsigned char > &buf)
Modifies the byte array by a random sequence of bytes generated by this random number generator.
Random()
Construct a random generator with the current time of day in milliseconds as the initial state.
virtual void nextBytes(unsigned char *buf, int size)
Modifies the byte array by a random sequence of bytes generated by this random number generator.
Random(unsigned long long seed)
Construct a random generator with the given seed as the initial state.
float nextFloat()
Generates a normally distributed random float number between 0.0 inclusively and 1....
#define DECAF_API
Definition Config.h:29
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25