Skip to content

Commit

Permalink
adding pcu_aa_count
Browse files Browse the repository at this point in the history
  • Loading branch information
ibaned committed Jan 12, 2015
1 parent 1b1271f commit d1f07ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pcu/pcu_aa.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,10 @@ pcu_aa_node* pcu_aa_find(pcu_aa_node* x, pcu_aa_tree t, pcu_aa_less* less)
return t;
}

int pcu_aa_count(pcu_aa_tree t)
{
if (pcu_aa_empty(t))
return 0;
return pcu_aa_count(t->left) + pcu_aa_count(t->right) + 1;
}

1 change: 1 addition & 0 deletions pcu/pcu_aa.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ bool pcu_aa_empty(pcu_aa_tree t);
pcu_aa_node* pcu_aa_insert(pcu_aa_node* x, pcu_aa_tree* t, pcu_aa_less* less);
pcu_aa_node* pcu_aa_remove(pcu_aa_node* x, pcu_aa_tree* t, pcu_aa_less* less);
pcu_aa_node* pcu_aa_find(pcu_aa_node* x, pcu_aa_tree t, pcu_aa_less* less);
int pcu_aa_count(pcu_aa_tree t);

#endif

0 comments on commit d1f07ea

Please sign in to comment.