c++ - Template Hash-Function for string and integers -
i creating hashtable class via template. although, can't seem find way maintain template nature when dealing strings or numerical datatype (more-so integers). code have works long hashkey of type string.
template<typename hashkey> size_t hashtable<hashkey>::myhash(const hashkey & x) const { unsigned int hashval = 0; (unsigned int = 0; < x; i++) hashval = (hashval << 5) ^ x[i] ^ hashval; homecoming hashval % hashtable.size(); };
would there way allow work using
unsigned int hashval = 0; hashval = (hashval << 5) ^ x ^ hashval; homecoming hashval % hashtable.size();
any help here?
c++ templates hash-function
No comments:
Post a Comment