Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // s is string of data to be hashed, recordLen is strlen(s)
- unsigned long hash2(char* s, int tableSize, int bucketSize, int recordLen) {
- unsigned long orVal;
- unsigned long remainder;
- for (orVal = 0; strlen(s) >= 4; s += 4) orVal ^= *reinterpret_cast<unsigned long*>(s);
- if (strlen(s) != 0) {
- strcpy(reinterpret_cast<char*>(&remainder),s);
- orVal ^= remainder;
- }
- return (orVal % tableSize) * bucketSize * recordLen;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement