tags:

views:

270

answers:

2

what is a good hashtable implementation for C? I need to use it with mpicc compiler. Delete function is not necessary.

+3  A: 

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).

unwind
glib is nice but it's so big that I wouldn't suggest to include it in your project just for that. If you also need all the other features glib has, though, I agree that would be the way to go.
Remo.D
+2  A: 

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.

Remo.D