I've used the Dan Bernstein hash for stuff like this in the past, but as pointed out, the number of bits you use will dictate how frequent a collision occurs. If you get too many collisions you lose the O(1) access time and revert to O(n) plus the cost of doing the hash function.
If you use STL, you could try something like this:
std::map< std::string, DWORD > identMap;
This will essentially hash a std::string into a DWORD and vice versa.
Show differencesHistory of post edits
#1Steve_Segreto
Posted 26 November 2012 - 01:50 AM
I've used the Dan Bernstein hash for stuff like this in the past, but as pointed out, the number of bits you use will dictate how frequent a collision is. If you get too many collisions you lose the O(1) access time and revert to O(n) plus the cost of doing the hash function.
If you use STL, you could try something like this:
std::map< std::string, DWORD > identMap;
This will essentially hash a std::string into a DWORD and vice versa.
If you use STL, you could try something like this:
std::map< std::string, DWORD > identMap;
This will essentially hash a std::string into a DWORD and vice versa.