bt.h
Appearance
< Projects
bt.h is a single-header red-black tree for C with string keys. Adding, finding and deleting are O(log n), and deleting keeps the tree balanced.
Walks in key order (bt_first/bt_next, or
for_bt_each) keep no state of their own, so they can nest.
The older bt_iter still works, but has a single state for
the whole program.
Usage
- Copy
bt.hinto your project. #define BT_IMPLEMENTATIONbefore including it, in exactly one file.#include "bt.h"wherever you need it.
The public API is documented in bt.h;
test.c is an example.
Note If you get implicit declaration of function strdup, include
bt.h before string.h, or define
_XOPEN_SOURCE >= 500 or
_POSIX_C_SOURCE >= 200809L.The tree is not type-agnostic yet.
See also
Categories:
- C libraries