Mon, 18 May 2015 19:49:03 +0200
added ucx_avl_count
ucx/avl.c | file | annotate | diff | comparison | revisions | |
ucx/avl.h | file | annotate | diff | comparison | revisions |
1.1 --- a/ucx/avl.c Mon May 18 19:12:32 2015 +0200 1.2 +++ b/ucx/avl.c Mon May 18 19:49:03 2015 +0200 1.3 @@ -214,3 +214,14 @@ 1.4 } 1.5 } 1.6 1.7 +static size_t ucx_avl_countn(UcxAVLNode *node) { 1.8 + if (node) { 1.9 + return 1 + ucx_avl_countn(node->left) + ucx_avl_countn(node->right); 1.10 + } else { 1.11 + return 0; 1.12 + } 1.13 +} 1.14 + 1.15 +size_t ucx_avl_count(UcxAVLTree *tree) { 1.16 + return ucx_avl_countn(tree->root); 1.17 +}
2.1 --- a/ucx/avl.h Mon May 18 19:12:32 2015 +0200 2.2 +++ b/ucx/avl.h Mon May 18 19:49:03 2015 +0200 2.3 @@ -173,7 +173,12 @@ 2.4 */ 2.5 void* ucx_avl_remove(UcxAVLTree *tree, intptr_t key); 2.6 2.7 - 2.8 +/** 2.9 + * Counts the nodes in the specified UcxAVLTree. 2.10 + * @param tree the AVL tree 2.11 + * @return the node count 2.12 + */ 2.13 +size_t ucx_avl_count(UcxAVLTree *tree); 2.14 2.15 #ifdef __cplusplus 2.16 }