diff options
Diffstat (limited to 'rb_tree.h')
-rw-r--r-- | rb_tree.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rb_tree.h b/rb_tree.h new file mode 100644 index 0000000..491e5b8 --- /dev/null +++ b/rb_tree.h @@ -0,0 +1,29 @@ +#ifndef RB_TREE_H_SENTRY +#define RB_TREE_H_SENTRY + +enum color_type { red, black }; + +struct node_type { + int key; + enum color_type color; + struct node_type *p; + struct node_type *left; + struct node_type *right; +}; +typedef struct node_type node; + +struct rb_tree_type { + node *root; + node *nil; +}; +typedef struct rb_tree_type rb_tree; + +void rb_tree_init(rb_tree *t); +void rb_tree_insert_node(rb_tree *t, node *cur_node); +void rb_tree_delete_node(rb_tree *t, node *cur_node); +void rb_tree_clear(rb_tree *t, node *root); +node* rb_tree_create_node(rb_tree *t, int num); +node* rb_tree_search(rb_tree *t, node *root, int num); +void rb_tree_print(rb_tree *t, node *root); + +#endif |