Merge branch 'master' into prog-loader
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / btrie.h
1 #ifndef __LUNAIX_SPARSE_H
2 #define __LUNAIX_SPARSE_H
3
4 #include <lunaix/ds/llist.h>
5 #include <lunaix/types.h>
6
7 #define BTRIE_BITS 4
8
9 struct btrie
10 {
11     struct btrie_node* btrie_root;
12     int truncated;
13 };
14
15 struct btrie_node
16 {
17     struct llist_header children;
18     struct llist_header siblings;
19     struct llist_header nodes;
20     struct btrie_node* parent;
21     u32_t index;
22     void* data;
23 };
24
25 void
26 btrie_init(struct btrie* btrie, u32_t trunc_bits);
27
28 void*
29 btrie_get(struct btrie* root, u32_t index);
30
31 void
32 btrie_set(struct btrie* root, u32_t index, void* data);
33
34 void*
35 btrie_remove(struct btrie* root, u32_t index);
36
37 void
38 btrie_release(struct btrie* tree);
39
40 #endif /* __LUNAIX_SPARSE_H */