git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unifying External Interrupt System (#51)
[lunaix-os.git]
/
lunaix-os
/
includes
/
lunaix
/
ds
/
btrie.h
diff --git
a/lunaix-os/includes/lunaix/ds/btrie.h
b/lunaix-os/includes/lunaix/ds/btrie.h
index bcf02500de3122a9ba7e8681cc6e0cfb55b93d14..d24cf84e56ae30bf762aaa8e3575b22cfeae324d 100644
(file)
--- a/
lunaix-os/includes/lunaix/ds/btrie.h
+++ b/
lunaix-os/includes/lunaix/ds/btrie.h
@@
-6,6
+6,9
@@
#define BTRIE_BITS 4
#define BTRIE_BITS 4
+/**
+ * key-sorted prefix tree
+ */
struct btrie
{
struct btrie_node* btrie_root;
struct btrie
{
struct btrie_node* btrie_root;
@@
-14,12
+17,13
@@
struct btrie
struct btrie_node
{
struct btrie_node
{
- struct llist_header children;
- struct llist_header siblings;
struct llist_header nodes;
struct btrie_node* parent;
unsigned long index;
void* data;
struct llist_header nodes;
struct btrie_node* parent;
unsigned long index;
void* data;
+
+ struct btrie_node** children;
+ int children_cnt;
};
void
};
void
@@
-28,9
+32,21
@@
btrie_init(struct btrie* btrie, unsigned int order);
void*
btrie_get(struct btrie* root, unsigned long index);
void*
btrie_get(struct btrie* root, unsigned long index);
+/**
+ * Set an object into btrie tree at given location,
+ * override if another object is already present.
+ */
void
btrie_set(struct btrie* root, unsigned long index, void* data);
void
btrie_set(struct btrie* root, unsigned long index, void* data);
+/**
+ * Map an object into btrie tree, return the index the object
+ * mapped to
+ */
+unsigned long
+btrie_map(struct btrie* root,
+ unsigned long start, unsigned long end, void* data);
+
void*
btrie_remove(struct btrie* root, unsigned long index);
void*
btrie_remove(struct btrie* root, unsigned long index);