C Data Structures — First-Class ADTs in C
A set of pointer-based data-structure libraries, each of which can be used on its own.
Overview
I wrote these structures while studying and then cleaned them up enough to share. The constraint I set myself was to treat every structure as a first-class abstract data type: the container is opaque, it stores pointers, and the operations are supplied through function pointers. That keeps the libraries generic without macros or generated code.
The libraries
Each structure lives in its own repository and is mounted here as a git submodule, so any single one can be cloned and used without the rest:
- Array — a dynamic array
- ArrayListConversionLib — conversions between arrays and lists
- Lists — a singly-linked
Shortlistand a doubly-linkedList - BSTs — a plain
BSTand anAdvancedBST - SymbleTable — a dynamic-array-backed symbol table
- CUtils — general utility functions
- TypesCollection — wrappers for the primitive types (Integer, Double, Float, Number)
Design notes
The code leans heavily on pointers and function pointers, which is the whole exercise: the user supplies comparison, copy and free functions, and the structure never needs to know what it is holding. Comments are partly in Italian, and the repository carries a clang-format configuration.
Because of the submodules, a recursive clone is required to pull the full set.
Why it is here
It is the least glamorous project I have published, and that is rather the point: manual memory management, opaque types, and designing an API that stays useful without knowing the payload type are fundamentals that show up in the systems work I do now.