A generic container library for C.
-
Include the appropriate header files in your code. Example:
#include <abstract/list.h> #include <linked_list.h>
-
Define a container as a pointer to an abstract container type. Initialize with a concrete "constructor." Example (list of C strings):
int keycmp(void *a, void *b) { return strcmp((char *)a, (char *)b); } list_t *list = linked_list_new(keycmp);
-
Interact with containers with the macros defined in the abstract container's header file. Example:
list_add(list, "foo"); list_add(list, "bar"); char *str = (char *)list_get(list, 0);
-
Free containers when they are no longer needed with the appropriate macro. Note: you are reponsible for freeing any dynamically allocated elements you store in the container. Example:
list_free(list);
> cd path/to/libbitbag
> make
> gcc -L path/to/libbitbag/lib -I path/to/libbitbag/include your_program.c
> export LD_LIBRARY_PATH=path/to/libbitbag/lib (DYLD_LIBRARY_PATH on some unices)
- Iterators.
- Hash table free.
- (Push / pop) (front / back) for lists.
- Thorough testing.
- Self-balancing binary search tree.
- Sorting.
- Heap for priority queues?
- Graphs?