ant-http/lib/bst.h

19 lines
623 B
C
Raw Permalink Normal View History

2020-08-06 18:45:12 +02:00
#ifndef BST_H
#define BST_H 1
2021-01-03 11:24:55 +01:00
#define bst_free(n) (bst_free_cb(n, NULL))
2020-08-06 18:45:12 +02:00
typedef struct _tree_node
{
int key;
void* data;
struct _tree_node* left;
struct _tree_node* right;
} bst_node_t;
2021-01-03 11:24:55 +01:00
void bst_free_cb(bst_node_t* root, void (*callback)(void*));
2020-08-06 18:45:12 +02:00
bst_node_t* bst_insert(bst_node_t* root, int key, void* data);
bst_node_t* bst_find_min(bst_node_t* root);
bst_node_t* bst_find_max(bst_node_t* root);
bst_node_t* bst_find(bst_node_t* root, int x);
bst_node_t* bst_delete(bst_node_t* root, int x);
void bst_for_each(bst_node_t* root, void (*callback)(bst_node_t*, void **, int), void** args, int argc);
#endif