Generic typesafe datastructures for C99 and up.
arr_t(T)
— A static array with runtime known lengthvec_t(T)
— A dynamic arrayheap_t(T)
— A priority queuellist_t(T)
— A singly linked listset_t(T)
— A hash setmap_t(K, V)
— A hash map with typesafe valuespool_allocator_t(T)
— A generic memory pool
There are also various utilities in /util.
This library implements most operations using macros which perform various index / pointer calculations behind the scenes and eventually perform typesafe array / pointer accesses. The only other library I found using this approach is stb_ds by Sean Barrett, which is also what initially inspired me to build this.
Most other libraries for generic typesafe datastructures in C use the preprocessor to instantiate implementations of specific datastructure and type parameter combinations.
An example of this is tylov/STC.
The downsides of that method are, that the symbols for each instantiation must be unique, so they usually contain the names of the type parameters (think map_int_long_put
instead of map_put
), and that the instantiation macro must explicitly be called for every type combination.