-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.h
More file actions
43 lines (28 loc) · 715 Bytes
/
Copy pathtree.h
File metadata and controls
43 lines (28 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef _TREE_H
#define _TREE_H
#include "ds_common.h"
#define max(a, b) (a) > (b) ? a : b
typedef enum {
DEF_SORT,
SORT_ASC,
SORT_DESC
} sort_t;
typedef struct tree_node {
void *data;
struct tree_node *lft;
struct tree_node *rgt;
int height;
} tree_node_t;
typedef struct tree {
tree_node_t *root;
cmp_func_t cmp_func;
del_func_t del_func;
} tree_t;
tree_t *tree_open(cmp_func_t cmp_func, del_func_t del_func);
int tree_close(tree_t *tree);
int tree_add(tree_t *tree, void *data);
int tree_del(tree_t *tree, void *data);
int tree_find(tree_t *tree, void *data);
void tree_foreach(tree_t *tree, visit_func_t visit_func, sort_t sort, void *ctx);
int tree_node_bf(tree_node_t *node);
#endif