Reputation: 1335
In school my teacher went over high performance spelling checking that uses a numeric hash, or key that represents a word. So instead of words, the keys are stored. Then the word to check is converted to its unique number using the same algorithm that was used on the dictionary. But I can't remember what this method is called, and I need to write a similar method.
Anyone know about this method to generate a unique number for a set of chars?
Upvotes: 0
Views: 487
Reputation: 66
Actually standard c++ library has a hash template structure for that:
#include <iostream>
#include <functional>
int main() {
std::string str = "Programmer";
std::size_t str_hash = std::hash<std::string>{}(str);
std::cout << str_hash ;
return 0;
}
Would output 2561445211.
"std::hash{}(str)" computes the hash value;
Upvotes: 1