issue#11: cds: changed __CDS_ guard prefix to CDSLIB_ for all .h files
[libcds.git] / tests / unit / alloc / random_gen.h
1 //$$CDS-header$$
2
3 // Random number geerator
4
5 #ifndef CPPUNIT_MEMORY_RANDOM_GEN_H
6 #define CPPUNIT_MEMORY_RANDOM_GEN_H
7
8
9 #include <boost/random/mersenne_twister.hpp>
10 #include <boost/random/uniform_int.hpp>
11 #include <boost/random/variate_generator.hpp>
12
13 namespace memory {
14     template <typename T>
15     class randomGen
16     {
17         boost::mt19937   m_rndGen;
18     public:
19         typedef T   random_type;
20
21         randomGen()
22         {}
23
24         random_type gen( random_type nMin, random_type nMax )
25         {
26             boost::uniform_int<random_type> dist(nMin, nMax);
27             return boost::variate_generator<boost::mt19937&, boost::uniform_int<random_type> >(m_rndGen, dist)();
28         }
29
30         /*
31         random_type operator()()
32         {
33             return gen( s_nMinBlockSize, s_nMaxBlockSize );
34         }
35         */
36
37         random_type operator()( random_type nMin, random_type nMax )
38         {
39             return gen( nMin, nMax );
40         }
41     };
42 }   // namespace memory
43
44 #endif // CPPUNIT_MEMORY_RANDOM_GEN_H