Hashtable implementation for C
what is a good hashtable implementation for C? I need to use it 开发者_开发知识库with mpicc compiler. Delete function is not necessary.
The one in glib is very nice. Not sure if it's too large and/or possible to isolate from the rest of glib, though.
Failing that, Pearson hashing seems to be a good starting point for implementing your own (it's a hash function optimized for machines with 8-bit registers).
If the keys are all known in advance, you may use a perfect hash generator avoid the space overhead that is implicit in hash tables.
If, on the other hand, you really need a full hash table, I would suggest a variation of Cuckoo Hashing (e.g. the d-ary version).
I've used with satisfaction a simplified version of the Hopscotch Hashing that works rather well even at higher load factors.
精彩评论