Help with Paul Senzee's Perfect Hash
I'm trying to port to Pascal the perfect hash program used in Cactus Kev's hand evaluator, written as a patch by Paul Senzee:
unsigned find_fast(unsigned u)
unsigned a, b, r;
u += 0xe91aaa35;
u ^= u >> 16;
u += u << 8;
u ^= u >> 4;
b = (u >> 8) & 0x1ff;
a = (u + (u << 2)) >> 19;
r = a ^ hash_adjust[b];
The only problem I'm having is figuring out the source of the hash adjust table
given in the penultimate line: "r = a ^ hash_adjust[b];"
How exactly is hash_adjust populated? And I assume the "^" is an XOR of a and the b element in that table, correct?
Thanks for any help.