diff options
author | scratko <m@scratko.xyz> | 2024-03-30 17:12:57 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-03-30 17:12:57 +0300 |
commit | ff69b8a8f2997c794ed4790dd84d2b3657f2f86e (patch) | |
tree | cf3dd97fac0a90e169708b64bfa6973f14ee4ed9 /rb_tree.h | |
download | red-black-tree-ff69b8a8f2997c794ed4790dd84d2b3657f2f86e.tar.gz red-black-tree-ff69b8a8f2997c794ed4790dd84d2b3657f2f86e.tar.bz2 red-black-tree-ff69b8a8f2997c794ed4790dd84d2b3657f2f86e.zip |
Initial commit
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 |