This documentation describes the Prokee module interface.
Static Methods:
countItems
uint32_t avltree::countItems(struct AVLContainer *node)
reset
void avltree::reset(struct AVLContainer *node)
destroy
void avltree::destroy(struct AVLContainer *node)
getNextNode
struct AVLContainer *avltree::getNextNode(struct AVLContainer *node)
findMin
struct AVLContainer *avltree::findMin(struct AVLContainer *node)
findMax
struct AVLContainer *avltree::findMax(struct AVLContainer *node)
searchNode
struct AVLContainer *avltree::searchNode(struct AVLContainer *node,uint32_t key)
searchNode2
struct AVLContainer *avltree::searchNode2(struct AVLContainer *node,uint32_t *key,uint32_t cnt)
getSubNodes
struct AVLContainer **avltree::getSubNodes(struct AVLContainer *node,uint32_t *key,uint32_t cnt,uint32_t *rcnt)
insertItem
struct AVLContainer *avltree::insertItem(struct AVLContainer *node,uint32_t key)
insertPath
struct AVLContainer *avltree::insertPath(struct AVLContainer *node,uint32_t *key,uint32_t cnt)
print_tree
void avltree::print_tree(FILE *f,struct AVLContainer *node)
print
void avltree::print(FILE *f,struct AVLContainer *node)
deleteItem
int avltree::deleteItem(struct AVLContainer *rootNode,uint32_t key)
deleteNode
int avltree::deleteNode(struct AVLContainer *rootNode,struct AVLContainer *node)
deleteNode2
int avltree::deleteNode2(struct AVLContainer *rootNode,uint32_t *key,uint32_t cnt)
deleteNode2_clean1
int avltree::deleteNode2_clean1(struct AVLContainer *rootNode,uint32_t *key,uint32_t cnt)
deleteNode2_cleanup
int avltree::deleteNode2_cleanup(struct AVLContainer *rootNode,uint32_t *key,uint32_t cnt)
Motivation
This module is misnamed.
It provides an implementation of an avl tree. Every node of this
tree may be used to store an int32_t value. Additionally, every
node may contain another avl tree. This allows to build
(non-binary) trees, where the children of every node are stored
in an avl tree.
The tree does not store key-value paires. It only stores an
uint32_t integer, which is referred to as key or value of the node.
Static Methods
countItems
Returns the number of child nodes of node
node.
Signature:
uint32_t avltree::countItems(struct AVLContainer *node)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
Return value:Number of child nodes.
createEmptyContainer
Creates a new empty node.
Signature:
struct AVLContainer *avltree::createEmptyContainer()
Return value:Returns a pointer to a new empty node.
reset
Destroys all child nodes (subtrees) of node
node.
Signature:
void avltree::reset(struct AVLContainer *node)
Parameters:
| struct AVLContainer * | node | [IN/OUT] | Pointer to a node. |
destroy
Destroys node
node and all its child nodes (subtrees).
Signature:
void avltree::destroy(struct AVLContainer *node)
Parameters:
| struct AVLContainer * | node | [IN/OUT] | Pointer to a node. |
getNextNode
Returns the next node (the node with the next higher value).
Signature:
struct AVLContainer *avltree::getNextNode(struct AVLContainer *node)
Parameters:
| struct AVLContainer * | node | [IN/OUT] | Pointer to a node. |
Return value:A pointer to a node. The function may return
NULL.
findMin
Returns the node with the minimum value.
(No two nodes should have the same value.)
Signature:
struct AVLContainer *avltree::findMin(struct AVLContainer *node)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
Return value:A pointer to a node.
findMax
Returns the node with the maximum value.
(No two nodes should have the same value.)
Signature:
struct AVLContainer *avltree::findMax(struct AVLContainer *node)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
Return value:A pointer to a node.
searchNode
Searches for the node with value
key.
(No two nodes should have the same value.)
Signature:
struct AVLContainer *avltree::searchNode(struct AVLContainer *node,uint32_t key)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
| uint32_t | key | | The value (or key) of the node. |
Return value:A pointer to a node.
searchNode2
Searches for the node with path stored in
key.
Signature:
struct AVLContainer *avltree::searchNode2(struct AVLContainer *node,uint32_t *key,uint32_t cnt)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
| uint32_t * | key | [IN] | The path (of values) to a node. |
| uint32_t | cnt | | The number of entries stored in key. |
Return value:A pointer to a node.
getSubNodes
Returns all sub-nodes of the node given by
key,
cnt.
Signature:
struct AVLContainer **avltree::getSubNodes(struct AVLContainer *node,uint32_t *key,uint32_t cnt,uint32_t *rcnt)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
| uint32_t * | key | [IN] | The path (of values) to a node. |
| uint32_t | cnt | | The number of entries stored in key. |
| uint32_t * | rcnt | [OUT] | Receives the number of returned node pointers. |
Return value:Pointer to child nodes. The function may return
NULL.
insertItem
Inserts a new node with value
key.
Signature:
struct AVLContainer *avltree::insertItem(struct AVLContainer *node,uint32_t key)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
| uint32_t | key | | The value (or key) of the node. |
Return value:A pointer to a node.
insertPath
Inserts a new node according to the path given by
key.
Signature:
struct AVLContainer *avltree::insertPath(struct AVLContainer *node,uint32_t *key,uint32_t cnt)
Parameters:
| struct AVLContainer * | node | [IN] | Pointer to a node. |
| uint32_t * | key | [IN] | The path (of values) to a node. |
| uint32_t | cnt | | The number of entries stored in key. |
Return value:A pointer to a node.
print_tree
Prints the avl tree (with
node as its root node).
Signature:
void avltree::print_tree(FILE *f,struct AVLContainer *node)
Parameters:
| FILE * | f | | Pointer to an opened file descriptor. |
| struct AVLContainer * | node | [IN] | Pointer to a node. |
print
Prints the (sub-)tree (starting from
node as its root).
Signature:
void avltree::print(FILE *f,struct AVLContainer *node)
Parameters:
| FILE * | f | | Pointer to an opened file descriptor. |
| struct AVLContainer * | node | [IN] | Pointer to a node. |
deleteItem
Deletes the node with value
key.
Signature:
int avltree::deleteItem(struct AVLContainer *rootNode,uint32_t key)
Parameters:
| struct AVLContainer * | rootNode | [IN/OUT] | Pointer to a node. |
| uint32_t | key | | The value (or key) of the node. |
Return value:-
deleteNode
Deletes the node
node.
Signature:
int avltree::deleteNode(struct AVLContainer *rootNode,struct AVLContainer *node)
Parameters:
| struct AVLContainer * | rootNode | [IN/OUT] | Pointer to a node. |
| struct AVLContainer * | node | [IN/OUT] | Pointer to a node. |
Return value:-
deleteNode2
Deletes the node given by
key,
cnt.
Signature:
int avltree::deleteNode2(struct AVLContainer *rootNode,uint32_t *key,uint32_t cnt)
Parameters:
| struct AVLContainer * | rootNode | [IN/OUT] | Pointer to a node. |
| uint32_t * | key | [IN] | The path (of values) to a node. |
| uint32_t | cnt | | The number of entries stored in key. |
Return value:-
deleteNode2_clean1
Deletes the node given by
key,
cnt and its parent node, if the parent node becomes empty.
Signature:
int avltree::deleteNode2_clean1(struct AVLContainer *rootNode,uint32_t *key,uint32_t cnt)
Parameters:
| struct AVLContainer * | rootNode | [IN/OUT] | Pointer to a node. |
| uint32_t * | key | [IN] | The path (of values) to a node. |
| uint32_t | cnt | | The number of entries stored in key. |
Return value:-
deleteNode2_cleanup
Deletes the node given by
key,
cnt and recursively all parent nodes, if they become empty.
The
rootNode will never by deleted, and may remain empty.
Signature:
int avltree::deleteNode2_cleanup(struct AVLContainer *rootNode,uint32_t *key,uint32_t cnt)
Parameters:
| struct AVLContainer * | rootNode | [IN/OUT] | Pointer to a node. |
| uint32_t * | key | [IN] | The path (of values) to a node. |
| uint32_t | cnt | | The number of entries stored in key. |
Return value:-