@@ -24,15 +24,19 @@ static const size_t BITS_PER_BLOCK = 8;
2424
2525// Forward declarations
2626
27+ typedef unsigned int hash_rounds_t ;
28+
29+ typedef unsigned int hash_t ;
30+
2731static void checkArchitecture ();
2832
2933static size_t calculateHashRounds (size_t size, size_t maxItems);
3034
31- static unsigned int djb2Hash (const string &text);
35+ static hash_t djb2Hash (const string &text);
3236
33- static unsigned int sdbmHash (const string &text);
37+ static hash_t sdbmHash (const string &text);
3438
35- static unsigned int doubleHash (unsigned int hash1, unsigned int hash2, unsigned int round);
39+ static hash_t doubleHash (hash_t hash1, hash_t hash2, hash_rounds_t round);
3640
3741static vector<BlockType> readVectorFromFile (const string &path);
3842
@@ -75,7 +79,7 @@ void BloomFilter::add(const string &element) {
7579 unsigned int hash1 = djb2Hash (element);
7680 unsigned int hash2 = sdbmHash (element);
7781
78- for (size_t i = 0 ; i < hashRounds; i++) {
82+ for (hash_rounds_t i = 0 ; i < hashRounds; i++) {
7983 unsigned int hash = doubleHash (hash1, hash2, i);
8084 size_t bitIndex = hash % bitCount;
8185 size_t blockIndex = bitIndex / BITS_PER_BLOCK;
@@ -89,7 +93,7 @@ bool BloomFilter::contains(const string &element) {
8993 unsigned int hash1 = djb2Hash (element);
9094 unsigned int hash2 = sdbmHash (element);
9195
92- for (size_t i = 0 ; i < hashRounds; i++) {
96+ for (hash_rounds_t i = 0 ; i < hashRounds; i++) {
9397 unsigned int hash = doubleHash (hash1, hash2, i);
9498 size_t bitIndex = hash % bitCount;
9599 size_t blockIndex = bitIndex / BITS_PER_BLOCK;
@@ -103,23 +107,23 @@ bool BloomFilter::contains(const string &element) {
103107 return true ;
104108}
105109
106- static unsigned int djb2Hash (const string &text) {
107- unsigned int hash = 5381 ;
110+ static hash_t djb2Hash (const string &text) {
111+ hash_t hash = 5381 ;
108112 for (const char &iterator : text) {
109113 hash = ((hash << 5 ) + hash) + iterator;
110114 }
111115 return hash;
112116}
113117
114- static unsigned int sdbmHash (const string &text) {
115- unsigned int hash = 0 ;
118+ static hash_t sdbmHash (const string &text) {
119+ hash_t hash = 0 ;
116120 for (const char &iterator : text) {
117121 hash = iterator + ((hash << 6 ) + (hash << 16 ) - hash);
118122 }
119123 return hash;
120124}
121125
122- static unsigned int doubleHash (unsigned int hash1, unsigned int hash2, unsigned int round) {
126+ static hash_t doubleHash (hash_t hash1, hash_t hash2, hash_rounds_t round) {
123127 switch (round) {
124128 case 0 :
125129 return hash1;
@@ -151,4 +155,4 @@ static vector<BlockType> readVectorFromStream(BinaryInputStream &in) {
151155
152156size_t BloomFilter::getBitCount () const {
153157 return bitCount;
154- }
158+ }
0 commit comments