enum COLOR { RED, BLACK }; /** * The Red-Black node struct definition */ typedef struct rb_node_t rb_node_t; struct rb_node_t { /* parent - RB_NODE_NULL for root */ rb_node_t *parent; /* left child - smaller key */ rb_node_t *left; /* right child - bigger key */ rb_node_t *right; /* the sorting is based on key */ void *key; /* data contained by the node */ void *data; /* color of the node */ enum COLOR color; }; /** * The Red-Black tree struct definition */ typedef struct rb_tree_t rb_tree_t; struct rb_tree_t { /* root of the tree */ rb_node_t *root; /* key size */ size_t key_size; /* data size */ size_t data_size; /* function used for sorting the keys */ int (*cmp)(const void *key1, const void *key2); };