{
c_avl_node_t *root;
int (*compare) (const void *, const void *);
+ int size;
};
struct c_avl_iterator_s
t->root = NULL;
t->compare = compare;
+ t->size = 0;
return (t);
}
} /* while (42) */
verify_tree (t->root);
+ ++t->size;
return (0);
} /* int c_avl_insert */
status = _remove (t, n);
verify_tree (t->root);
+ --t->size;
return (status);
} /* void *c_avl_remove */
{
free (iter);
}
+
+int c_avl_size (c_avl_tree_t *t)
+{
+ if (t == NULL)
+ return (0);
+ return (t->size);
+}
int c_avl_iterator_prev (c_avl_iterator_t *iter, void **key, void **value);
void c_avl_iterator_destroy (c_avl_iterator_t *iter);
+/*
+ * NAME
+ * c_avl_size
+ *
+ * DESCRIPTION
+ * Return the size (number of nodes) of the specified tree.
+ *
+ * PARAMETERS
+ * `t' AVL-tree to get the size of.
+ *
+ * RETURN VALUE
+ * Number of nodes in the tree, 0 if the tree is empty or NULL.
+ */
+int c_avl_size (c_avl_tree_t *t);
+
#endif /* UTILS_AVLTREE_H */