Go to the documentation of this file.00001
00002
00003 #include "osl/hash/hashRandomPair.h"
00004 #include <boost/random/mersenne_twister.hpp>
00005 #include <boost/random/uniform_smallint.hpp>
00006 #include <boost/random/variate_generator.hpp>
00007
00008 std::pair<char,char>
00009 osl::hash::HashRandomPair::table[osl::hash::HashRandomPair::Length];
00010 bool osl::hash::HashRandomPair::is_initialized = 0;
00011
00012 void osl::hash::HashRandomPair::setUp(unsigned int seed, unsigned int prob100)
00013 {
00014 boost::mt19937 mt19937(seed);
00015 boost::uniform_smallint<> uniform100(0, 99);
00016 boost::variate_generator<boost::mt19937, boost::uniform_smallint<> >
00017 random100(mt19937, uniform100);
00018
00019 for (size_t i=0; i<Length; ++i) {
00020 const unsigned int u = random100();
00021 if (u < prob100)
00022 table[i] = std::make_pair(1,0);
00023 else if (u < prob100*2)
00024 table[i] = std::make_pair(0,1);
00025 else
00026 table[i] = std::make_pair(0,0);
00027 }
00028 is_initialized = 1;
00029 }
00030
00031
00032
00033
00034
00035