bloodhound  0.2.0
AVL self-balancing binary search tree with intrusive nodes.
Bloodhound

Bloodhound is an ANSI C implementation of an AVL self-balancing binary search tree with intrusive nodes.

Installation

```sh git clone https://github.com/Gregory-Meyer/bloodhound.git mkdir bloodhound/build cd bloodhound/build cmake .. -DCMAKE_BUILD_TYPE=Release cmake –build . -j nproc cmake –build . –target test sudo cmake –build . –target install

1 ## Usage
2 
3 ```c
4 #include <bloodhound.h>
5 
6 typedef struct Node {
7  AvlNode node;
8  const char *key;
9  int value;
10 } Node;
11 
12 static int node_compare(const AvlNode *lhs, const AvlNode *rhs, void*) {
13  return strcmp(((Node*) lhs)->key, ((Node*) rhs)->key);
14 }
15 
16 static int node_het_compare(const void *lhs, const AvlNode *rhs, void*) {
17  return strcmp((const char*) lhs, ((Node*) rhs)->key);
18 }
19 
20 static void node_delete(AvlNode *, void*) { }
21 
22 int main(void) {
23  AvlTree map;
24  Node first = {{NULL, NULL, 0}, "foo", 5};
25  Node second = {{NULL, NULL, 0}, "foo", 10};
26  Node third = {{NULL, NULL, 0}, "bar", 5};
27  Node *node = NULL;
28 
29  AvlTree_new(&map, node_compare, NULL, node_delete, NULL);
30 
31  node = (Node*) AvlTree_insert(&map, &first.node);
32  assert(!node);
33 
34  node = (Node*) AvlTree_insert(&map, &second.node);
35  assert(node == &first);
36 
37  node = (Node*) AvlTree_insert(&map, &third.node);
38  assert(!node);
39 
40  node = (Node*) AvlTree_remove(&map, "bar", node_het_compare, NULL);
41  assert(node == &third);
42 
43  node = (Node*) AvlTree_get_mut(&map, "foo", node_het_compare, NULL);
44  assert(node == &second);
45 
46  AvlTree_drop(&map);
47 }

License

bloodhound is licensed under the MIT license.