diff --git a/cxxmph/mphtable.cc b/cxxmph/mphtable.cc index 6f6a788..8d461c2 100644 --- a/cxxmph/mphtable.cc +++ b/cxxmph/mphtable.cc @@ -165,8 +165,8 @@ void MPHTable::Ranking() { cmph_uint32 MPHTable::Search(const key_type& key) const { cmph_uint32 h[3]; - // for (int i = 0; i < 3; ++i) h[i] = hash_function_[i](key); - hash_function_[0](key, h); + for (int i = 0; i < 3; ++i) h[i] = hash_function_[i](key); + // hash_function_[0](key, h); h[0] = h[0] % r_; h[1] = h[1] % r_ + r_; h[2] = h[2] % r_ + (r_ << 1); diff --git a/cxxmph/mphtable.h b/cxxmph/mphtable.h index 84d56df..d130ace 100644 --- a/cxxmph/mphtable.h +++ b/cxxmph/mphtable.h @@ -22,7 +22,7 @@ class MPHTable { // This class could be a template for both key type and hash function, but we // chose to go with simplicity. typedef StringPiece key_type; - typedef RandomlySeededHashFunction hasher_type; + typedef RandomlySeededHashFunction hasher_type; MPHTable(double c = 1.23, cmph_uint8 b = 7) : c_(c), b_(b) { } ~MPHTable() {} @@ -82,8 +82,8 @@ bool MPHTable::Reset(ForwardIterator begin, ForwardIterator end) { std::vector queue; while (1) { cerr << "Iterations missing: " << iterations << endl; - // for (int i = 0; i < 3; ++i) hash_function_[i] = hasher_type(); - hash_function_[0] = hasher_type(); + for (int i = 0; i < 3; ++i) hash_function_[i] = hasher_type(); + // hash_function_[0] = hasher_type(); cerr << "Seed: " << hash_function_[0].seed << endl; if (Mapping(begin, end, &edges, &queue)) break; else --iterations; @@ -103,8 +103,8 @@ bool MPHTable::Mapping( TriGraph graph(n_, m_); for (ForwardIterator it = begin; it != end; ++it) { cmph_uint32 h[3]; - // for (int i = 0; i < 3; ++i) h[i] = hash_function_[i](*it); - hash_function_[0](*it, h); + for (int i = 0; i < 3; ++i) h[i] = hash_function_[i](*it); + // hash_function_[0](*it, h); cmph_uint32 v0 = h[0] % r_; cmph_uint32 v1 = h[1] % r_ + r_; cmph_uint32 v2 = h[2] % r_ + (r_ << 1); diff --git a/cxxmph/mphtable_test.cc b/cxxmph/mphtable_test.cc index 8986ee0..c444b49 100644 --- a/cxxmph/mphtable_test.cc +++ b/cxxmph/mphtable_test.cc @@ -17,6 +17,10 @@ int main(int argc, char** argv) { keys.push_back("joao"); keys.push_back("maria"); keys.push_back("bruno"); + keys.push_back("paula"); + keys.push_back("diego"); + keys.push_back("diogo"); + keys.push_back("algume"); MPHTable mphtable; assert(mphtable.Reset(keys.begin(), keys.end()));