I need an algorithm to hash strings (titles of wikipedia articles). How does this look? Any particular weaknesses?
(this is inspired by the Zobrist hashing algorithm Zobrist hashing - Wikipedia, the free encyclopedia)
There are about 4000000 articles (and hence titles), so I thought 32-bit hash should be good enough?Code:unsigned int keys[256][MAX_STRING_LENGTH]; //filled with randomly generated numbers unsigned int hash_string(std::string s) { unsigned int hash = 0; for (size_t i = 0; i < s.length(); ++i) { hash ^= zobrist_keys[s[i]][i]; } return hash; }



LinkBack URL
About LinkBacks


