@@ -49,10 +49,12 @@ POSSIBILITY OF SUCH DAMAGE.
49
49
* as a mapping (searching for a value based on its key), or
50
50
* as a set of keys which is always ordered.
51
51
*
52
- * To create a new AVL tree, use @ref avltree_new.
52
+ * To create a new AVL tree, use @ref avltree_new. To destroy
53
+ * an AVL tree, use @ref avltree_free.
53
54
*
54
55
* To insert a new key-value pair into an AVL tree, use
55
- * @ref avltree_insert.
56
+ * @ref avltree_insert. To remove an entry from an
57
+ * AVL tree, use @ref avltree_remove or @ref avltree_remove_node.
56
58
*
57
59
* To search an AVL tree, use @ref avltree_lookup or
58
60
* @ref avltree_lookup_node.
@@ -114,6 +116,14 @@ typedef int (*AVLTreeCompareFunc)(void *data1, void *data2);
114
116
115
117
AVLTree * avltree_new (AVLTreeCompareFunc compare_func );
116
118
119
+ /**
120
+ * Destroy an AVL tree.
121
+ *
122
+ * @param tree The tree to destroy.
123
+ */
124
+
125
+ void avltree_free (AVLTree * tree );
126
+
117
127
/**
118
128
* Insert a new key-value pair into an AVL tree.
119
129
*
@@ -135,6 +145,19 @@ AVLTreeNode *avltree_insert(AVLTree *tree, void *key, void *value);
135
145
136
146
void avltree_remove_node (AVLTree * tree , AVLTreeNode * node );
137
147
148
+ /**
149
+ * Remove an entry from a tree, specifying the key of the node to
150
+ * remove.
151
+ *
152
+ * @param tree The tree.
153
+ * @param key The key of the node to remove.
154
+ * @return Zero (false) if no node with the specified key was
155
+ * found in the tree, non-zero (true) if a node with
156
+ * the specified key was removed.
157
+ */
158
+
159
+ int avltree_remove (AVLTree * tree , void * key );
160
+
138
161
/**
139
162
* Search an AVL tree for a node with a particular key. This uses
140
163
* the tree as a mapping.
@@ -228,12 +251,6 @@ AVLTreeNode *avltree_node_parent(AVLTreeNode *node);
228
251
229
252
int avltree_subtree_height (AVLTreeNode * node );
230
253
231
-
232
- /******************** debug for removal ******************************/
233
-
234
- void avltree_print_tree (AVLTree * tree );
235
- int avltree_check_balanced (AVLTree * tree );
236
-
237
254
#ifdef __cplusplus
238
255
}
239
256
#endif
0 commit comments