../
Algds is a type-safe generic algorithms and data structures library for C, which includes:
git clone https://git.mistivia.com/algds.git
make
make install
make test
For example, if you have a custom type FancyThing, and you want a linked list of FancyThings. Just add LIST_DEF_AS(FancyThing, FancyList) to the header file, and LIST_IMPL_AS(FancyThing, FancyList) to a source file, and you get a new type FancyList, and many functions for free:
FancyList_createFancyLists_push_backFancyList_push_frontFancyList_pop_backFancyList_pop_frontAnd if you want a hash table with FancyThing as key, and a integer as value. First, define and implement 2 functions:
uint64_t FancyThing_hash(FancyThing self)bool FancyThing_eq(FancyThing a, FancyThing b)These functions just act like how typeclass/trait/concept works in Haskell/Rust/C++. And we provide mmhash to help you build FancyThing_hash.
Then you can add HASH_TABLE_DEF_AS(FancyThing, Int, FancyTable) to the header file, and HASH_TABLE_IMPL_AS(FancyThing, Int, FancyTable) to a source file. Then you get a new type FancyTable and its functions:
FancyTable_createFancyTable_freeFancyTable_insertFancyTable_findAnd other data structures follow similar patterns.
Mistivia - https://mistivia.com