From 7aba1b9c1a40ce84b2f9a42988697b7ebd464ee0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 28 Sep 2011 21:29:15 +0000 Subject: Add destructor parameter and zix_tree_size git-svn-id: http://svn.drobilla.net/zix/trunk@41 df6676b4-ccc9-40e5-b5d6-7c4628a128e3 --- zix/common.h | 5 +++++ zix/tree.h | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'zix') diff --git a/zix/common.h b/zix/common.h index a7edf76..8ed0b0b 100644 --- a/zix/common.h +++ b/zix/common.h @@ -60,6 +60,11 @@ typedef int (*ZixComparator)(const void* a, const void* b, void* user_data); Function for testing equality of two elements. */ typedef bool (*ZixEqualFunc)(const void* a, const void* b); + +/** + Function to destroy an element. +*/ +typedef void (*ZixDestroyFunc)(const void* ptr); /**@} */ diff --git a/zix/tree.h b/zix/tree.h index cdcec10..378db28 100644 --- a/zix/tree.h +++ b/zix/tree.h @@ -18,6 +18,7 @@ #define ZIX_TREE_H #include +#include #include "zix/common.h" @@ -46,7 +47,10 @@ typedef struct ZixTreeNodeImpl ZixTreeIter; Create a new (empty) tree. */ ZixTree* -zix_tree_new(bool allow_duplicates, ZixComparator cmp, void* cmp_data); +zix_tree_new(bool allow_duplicates, + ZixComparator cmp, + void* cmp_data, + ZixDestroyFunc destroy); /** Free @a t. @@ -54,6 +58,12 @@ zix_tree_new(bool allow_duplicates, ZixComparator cmp, void* cmp_data); void zix_tree_free(ZixTree* t); +/** + Return the number of elements in @a t. +*/ +size_t +zix_tree_size(ZixTree* t); + /** Insert the element @a e into @a t and point @a ti at the new element. */ -- cgit v1.2.1