From ff69b8a8f2997c794ed4790dd84d2b3657f2f86e Mon Sep 17 00:00:00 2001 From: scratko Date: Sat, 30 Mar 2024 17:12:57 +0300 Subject: Initial commit --- rb_tree.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rb_tree.h (limited to 'rb_tree.h') 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 -- cgit v1.2.3