summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-01-06 11:19:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-01-06 15:19:41 +0000
commit18ad91eec1a1c23d676355d1270fe4b7b503d262 (patch)
tree27767bc2f603d60e7a123fe88e591171f0f36cf4 /comphelper
parentf86a1dbf2a6761b23f9430b6bc61e789190290c9 (diff)
boost::random->std::random
Change-Id: I1b823b6c17b731e427bff88c6fff7897f66ddb5c
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/random.cxx21
1 files changed, 11 insertions, 10 deletions
diff --git a/comphelper/source/misc/random.cxx b/comphelper/source/misc/random.cxx
index 4da4acb84d7a..4a96b59672f8 100644
--- a/comphelper/source/misc/random.cxx
+++ b/comphelper/source/misc/random.cxx
@@ -10,12 +10,13 @@
* Copyright (C) 2012 Tino Kluge <tino.kluge@hrz.tu-chemnitz.de>
*/
-#include <boost/random.hpp>
#include <comphelper/random.hxx>
#include <rtl/instance.hxx>
+#include <assert.h>
+#include <random>
// this is nothing but a simple wrapper around
-// the boost random generators
+// the std::random generators
namespace comphelper
{
@@ -23,21 +24,21 @@ namespace rng
{
// underlying random number generator
-// boost::mt19937 implements the Mersenne twister algorithm which
+// std::mt19937 implements the Mersenne twister algorithm which
// is fast and has good statistical properties, it produces integers
// in the range of [0, 2^32-1] internally
// memory requirement: 625*sizeof(uint32_t)
// http://en.wikipedia.org/wiki/Mersenne_twister
-#define BOOST_RNG_ALGO boost::mt19937
+#define STD_RNG_ALGO std::mt19937
struct RandomNumberGenerator
{
- BOOST_RNG_ALGO global_rng;
+ STD_RNG_ALGO global_rng;
RandomNumberGenerator()
{
// initialises the state of the global random number generator
// should only be called once.
- // (note, a few boost::variate_generator<> (like normal) have their
+ // (note, a few std::variate_generator<> (like normal) have their
// own state which would need a reset as well to guarantee identical
// sequence of numbers, e.g. via myrand.distribution().reset())
global_rng.seed(time(NULL));
@@ -55,21 +56,21 @@ void reseed(int i)
// uniform ints [a,b] distribution
int uniform_int_distribution(int a, int b)
{
- boost::random::uniform_int_distribution<int> dist(a, b);
+ std::uniform_int_distribution<int> dist(a, b);
return dist(theRandomNumberGenerator::get().global_rng);
}
// uniform ints [a,b] distribution
unsigned int uniform_uint_distribution(unsigned int a, unsigned int b)
{
- boost::random::uniform_int_distribution<unsigned int> dist(a, b);
+ std::uniform_int_distribution<unsigned int> dist(a, b);
return dist(theRandomNumberGenerator::get().global_rng);
}
// uniform size_t [a,b] distribution
size_t uniform_size_distribution(size_t a, size_t b)
{
- boost::random::uniform_int_distribution<size_t> dist(a, b);
+ std::uniform_int_distribution<size_t> dist(a, b);
return dist(theRandomNumberGenerator::get().global_rng);
}
@@ -77,7 +78,7 @@ size_t uniform_size_distribution(size_t a, size_t b)
double uniform_real_distribution(double a, double b)
{
assert(a < b);
- boost::random::uniform_real_distribution<double> dist(a, b);
+ std::uniform_real_distribution<double> dist(a, b);
return dist(theRandomNumberGenerator::get().global_rng);
}