12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #pragma once
- #include <common/glib.h>
- struct bt_node_t
- {
- struct bt_node_t *left;
- struct bt_node_t *right;
- struct bt_node_t *parent;
- void *value;
- } __attribute__((aligned(sizeof(long))));
- struct bt_root_t
- {
- struct bt_node_t *bt_node;
- int32_t size;
- int (*cmp)(void *a, void *b);
-
- int (*release)(void *value);
- };
- struct bt_root_t *bt_create_tree(struct bt_node_t *node, int (*cmp)(void *a, void *b), int (*release)(void *value));
- struct bt_node_t *bt_create_node(struct bt_node_t *left, struct bt_node_t *right, struct bt_node_t *parent, void *value);
- int bt_insert(struct bt_root_t *root, void *value);
- int bt_query(struct bt_root_t *root, void *value, uint64_t *ret_addr);
- int bt_delete(struct bt_root_t *root, void *value);
- int bt_destroy_tree(struct bt_root_t *root);
|