PDA

View Full Version : Hash Maps in C



JDShu
January 28th, 2010, 06:16 AM
Hey guys, does anybody know what the standard practice is for getting hash maps in C? I use the STL in C++ and Python has the dictionaries, but I can't find any agreed upon solution for C.

fuzZzball
January 28th, 2010, 07:06 AM
A while ago I was searching for something similar, dunno if this is what you need, You can take a look though :D

http://ubuntuforums.org/showthread.php?t=1222055

JDShu
January 28th, 2010, 07:21 AM
Thanks! Its certainly not as pretty to use as hash functions in other languages, but its better than nothing.

MadCow108
January 28th, 2010, 08:45 AM
there is no real agreed practice, as the C standard does not contain any complex containers, nor does it set any requirements/recommendations on what a good implementation is.

glib's hash table:
http://library.gnome.org/devel/glib/stable/glib-Hash-Tables.html

uses tons of macros to make it reasonably easy to use, bsd license:
http://uthash.sourceforge.net/

this one that looks quite sophisticated but I never used it. You should probably read the licesne before considering to use it.
http://www.sunrisetel.net/software/devtools/sunrise-data-dictionary.shtml

JDShu
January 28th, 2010, 04:19 PM
Thank you very much for answering! I guess I'll have to do some experimenting.