From 22c32ae8649e8540198942b33d4bab72c4ea7238 Mon Sep 17 00:00:00 2001 From: Christian C Date: Sun, 23 Mar 2025 15:34:48 -0700 Subject: Userspace types --- include/lib/algo/avl_tree.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'include/lib/algo/avl_tree.h') diff --git a/include/lib/algo/avl_tree.h b/include/lib/algo/avl_tree.h index 4400aa6..0221952 100644 --- a/include/lib/algo/avl_tree.h +++ b/include/lib/algo/avl_tree.h @@ -2,6 +2,7 @@ #define INC_LIB_ALGO_AVL_TREE_H #include +#include #include #include #include @@ -10,42 +11,42 @@ typedef bool_t (*AvlComparator)(void*, void*); -struct AVLNode { +typedef struct AVLNode { void* data; AvlComparator compare; struct AVLNode* left; struct AVLNode* right; AvlHeight_t height; -}; +} AVLNode; // Get the height of an AVL node -AvlHeight_t get_height(struct AVLNode* node); +AvlHeight_t get_height(AVLNode* node); // Get the Maximum Height between two AvlHeight_t max_height(AvlHeight_t a, AvlHeight_t b); // Get the balance factor of a node -ssize_t get_balance_factor(struct AVLNode* node); +ssize_t get_balance_factor(AVLNode* node); // Rotate an AVL node right -struct AVLNode* right_rotate(struct AVLNode* parent); +AVLNode* right_rotate(AVLNode* parent); // Rotate an AVL node left -struct AVLNode* left_rotate(struct AVLNode* parent); +AVLNode* left_rotate(AVLNode* parent); // Create AVL node -struct AVLNode* create_avl_node(void* data, AvlComparator compare); +AVLNode* create_avl_node(void* data, AvlComparator compare); // Insert data into AVL tree -struct Result avl_insert(struct AVLNode* node, void* data, AvlComparator compare); +Result avl_insert(AVLNode* node, void* data, AvlComparator compare); // In-order traversal print pointer -void print_in_order(struct AVLNode* root); +void print_in_order(AVLNode* root); // Free avl tree nodes starting at root -void free_avl_tree(struct AVLNode* root); +void free_avl_tree(AVLNode* root); // Free avl tree and their data starting at root -void free_avl_tree_nodes(struct AVLNode* root); +void free_avl_tree_nodes(AVLNode* root); #endif -- cgit v1.2.1