aboutsummaryrefslogtreecommitdiff
path: root/include/lib/algo/avl_tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lib/algo/avl_tree.h')
-rw-r--r--include/lib/algo/avl_tree.h23
1 files changed, 12 insertions, 11 deletions
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 <lib/bool.h>
+#include <lib/monad.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -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