From 86c16a3c4cefd0b46bdff256367bb5bd0aba1191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Mon, 20 May 2013 23:09:42 +0200 Subject: [PATCH] Add documentation --- include/ucore/rbtree.h | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/ucore/rbtree.h b/include/ucore/rbtree.h index 57aaccd..bde88ef 100644 --- a/include/ucore/rbtree.h +++ b/include/ucore/rbtree.h @@ -26,11 +26,66 @@ struct RBTree { 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); + +/** 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); + +/** 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); + +/** 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); + +/** 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); + +/** 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); #ifdef __cplusplus