4 typedef unsigned long long uint64;
6 typedef unsigned int uint;
20 mersenneRNG(
uint32 maxval) : mtr(),n(maxval) {};
22 return mtr.randInt(n);
24 void seed(
uint32 seedval) {
38 template <
typename hashvaluetype>
39 hashvaluetype maskfnc(uint64_t bits) {
41 assert(bits<=
sizeof(hashvaluetype)*8);
42 hashvaluetype x =
static_cast<hashvaluetype
>(1) << (bits - 1);
46 template <
typename hashvaluetype = u
int32,
typename chartype =
unsigned char>
49 CharacterHash(hashvaluetype maxval) {
50 if(
sizeof(hashvaluetype) <=4) {
51 mersenneRNG randomgenerator(maxval);
52 for(
size_t k =0; k<nbrofchars; ++k)
53 hashvalues[k] = static_cast<hashvaluetype>(randomgenerator());
54 }
else if (
sizeof(hashvaluetype) == 8) {
55 mersenneRNG randomgenerator(maxval>>32);
56 mersenneRNG randomgeneratorbase((maxval>>32) ==0 ? maxval : 0xFFFFFFFFU);
57 for(
size_t k =0; k<nbrofchars; ++k)
58 hashvalues[k] = static_cast<hashvaluetype>(randomgeneratorbase())
59 | (
static_cast<hashvaluetype
>(randomgenerator()) << 32);
60 }
else throw runtime_error(
"unsupported hash value type");
63 enum {nbrofchars = 1 << (
sizeof(chartype)*8 )};
65 hashvaluetype hashvalues[1 << (
sizeof(chartype)*8 )];
unsigned long long uint64