Add documentation

This commit is contained in:
Nils O. Selåsdal
2013-05-20 23:09:42 +02:00
parent ce0f28c04a
commit 86c16a3c4c
+55
View File
@@ -26,11 +26,66 @@ struct RBTree {
int (*compare)(const void *a, const void *b); int (*compare)(const void *a, const void *b);
}; };
/** Remove a node from the tree.
*
* @param root Root of the tree
* @param node Node to remove, the node must exist in the tree
*/
void uc_rb_remove(RBTree *root, RBNode *node); void uc_rb_remove(RBTree *root, RBNode *node);
/** Find a node in the tree.
*
* The value to find will be in a node->data pointer, the compare
* function of the tree is used to find the matching item.
*
* @param root Root of the tree
* @param val The value to find.
* @return the found node
*/
RBNode *uc_rb_find(RBTree *root, const void *val); RBNode *uc_rb_find(RBTree *root, const void *val);
/** insert a new node
*
* The actual value to insert must be in node->data.
* Of node->data matches an existing item in the tree,
* the existing node will be replaced and returned.
*
* @param root Root of the tree
* @param child The node to insert
* @return NULL, or an existing node if the new node replaced
* an existing node.
*/
RBNode *uc_rb_insert(RBTree *root, RBNode *child); RBNode *uc_rb_insert(RBTree *root, RBNode *child);
/** get the first node in the tree.
* the tree keeps the items in a sorted order, this
* will be the node where the compare function determins as the
* smallest node.
*
* @param root Root of the tree
* @return the first node, or null if the tree is empty
*/
RBNode *uc_rb_first(const RBTree *root); RBNode *uc_rb_first(const RBTree *root);
/** Get the next node in the tree.
* the tree keeps the items in a sorted order, this
* will be the node after, based on the compare function ,
* the given node
*
* @param node The previous node
* @return the node after the passed in node, or NULL if the
* passed in node was the last.
*/
RBNode *uc_rb_next(RBNode *node); RBNode *uc_rb_next(RBNode *node);
/** Get the last node in the tree.
* the tree keeps the items in a sorted order, this
* will be the node where the compare function determins as the
* greatest node.
*
* @param root Root of the tree
* @return the last node, or null if the tree is empty
*/
RBNode *uc_rb_last(const RBTree *root); RBNode *uc_rb_last(const RBTree *root);
#ifdef __cplusplus #ifdef __cplusplus