CompuServe Thread

#amigados bitmap

3 messages in this thread
#115910From: Ariel ButlerMar 27, 1988 1:58 PM
Pat: Here is the Hash function, courtesy of Neil Katin: hash(s) unsigned char *s; int i; int res; unsigned char *sp; unsigned c; res = strlen(s); for (i = 1, sp = s; *sp ; i++, sp++) { c = *sp; if ( c >= 'a' && c <= 'z' ) { c = c – 'a' + 'A'; } res = (( res * 13 + c) & 0x7FF); } return (res); } Note: The computed hash value is the longword offset into the directory block, not into the hash table. Also, don't forget to use 32 bit integers as the default.
#116151From: Nick Sullivan/TransactorMar 28, 1988 6:40 PM
Ariel, I _hope_ that's not that actual code they use to compute the hash function… I hate to think of 'i' being initialized and incremented all those times to no purpose whenever a file name is referenced.henever
#116325From: Ariel ButlerMar 29, 1988 2:35 PM
Who knows? The original snippet comes from Usenet, and is attributed to Neil Katin. If this is the actual code, or just an educational example, is something best determined by the parties in question. 🙂