I'm trying to build simple open addressing via linear probing hash tables where I store phone numbers for keys of string names. I am using a tested and tried string hash function called FNV. I'm using g++ compiler that came with CodeBlocks IDE and when I compile, it complains w/ this message:warning: this decimal constant is unsigned only in ISO C90
Code:unsigned fnv_hash ( string key, int len ) { unsigned h = 2166136261; int i; for ( i = 0; i < len; i++ ) h = ( h * 16777619 ) ^ key[i]; return h; } int main() { int phonebook_1[10] = {0,0,0,0,0,0,0,0,0,0};//always initialize size since specific compilers say its ok so don't get comfy w/ bad practices int size_1 = 10; string name_1 = "Cooke"; int bucket = fnv_hash ( name_1, size_1 ); phonebook_1[bucket] = 1234567; return 0; }
Here is the src: Eternally Confuzzled - The Art of Hashing
BTW: when I type in g++ -v, it shows the gcc version:
gcc version 4.4.1 (TDM-2 mingw32)



3Likes
LinkBack URL
About LinkBacks




