LuaHashMap: An easy to use hash table library for C

LuaHashMap is a hash table library for C.

I write a lot of code in C for maximum portability. But I'm tired of not having common data structures available to me and needing to reinvent them for C. I also tend to use Lua in a lot of my projects. Lua already has a proven hash table implementation, so I decided to leverage that fact and write a convenience API to make using it for C even easier.  And I'm licensing this under MIT so I (or anybody else) never have to write it again.

LuaHashMap lets you use strings (const char*), pointers (void*), floating point numbers (lua_Number), and integers (lua_Integer) as keys/values. You don't really need to know anything about Lua; the API hides the Lua details. Lua is small, lightweight, self-contained, and fast so if you aren't already using it in your project, there is minimal impact in including it.

The code should work on any C compiler (including Visual Studio and its ancient/crappy/nerfed C89 compiler). But using some stragetic #ifdefs, C99 and C11 features are utilized when available to avoid being held back from modern advances in the C standard.


Please go the Documentation Page for a full overview of LuaHashMap.


For entertainment, check out the Hash Table Benchmarks and root for your favorite language.


License: MIT


© PlayControl Software, LLC