From 4547add54e051067e450ad13115d7b864c14a384 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Sep 2011 14:48:14 +0000 Subject: Make tree methods return ZixStatus instead of int where appropriate. Move ZixComparator to common.h. git-svn-id: http://svn.drobilla.net/zix/trunk@8 df6676b4-ccc9-40e5-b5d6-7c4628a128e3 --- zix/common.h | 5 +++++ zix/tree.h | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'zix') diff --git a/zix/common.h b/zix/common.h index dd86a8b..ee18664 100644 --- a/zix/common.h +++ b/zix/common.h @@ -47,6 +47,11 @@ typedef enum { ZIX_STATUS_EXISTS, } ZixStatus; +/** + Function for comparing two elements. +*/ +typedef int (*ZixComparator)(const void* a, const void* b, void* user_data); + /** @} */ diff --git a/zix/tree.h b/zix/tree.h index 8639d25..ccaf06e 100644 --- a/zix/tree.h +++ b/zix/tree.h @@ -32,11 +32,6 @@ extern "C" { @{ */ -/** - Function for comparing two elements. -*/ -typedef int (*ZixComparator)(const void* a, const void* b, void* user_data); - /** A balanced binary search tree. */ @@ -67,24 +62,24 @@ zix_tree_free(ZixTree* t); /** Insert the element @a e into @a t and point @a ti at the new element. */ -int +ZixStatus zix_tree_insert(ZixTree* t, const void* e, ZixTreeIter* ti); /** Remove the item pointed at by @a ti from @a t. */ -int +ZixStatus zix_tree_remove(ZixTree* t, ZixTreeIter ti); /** Set @a ti to be the largest element <= @a e in @a t. If no such item exists, @a ti is set to NULL. */ -int +ZixStatus zix_tree_find(const ZixTree* t, const void* e, ZixTreeIter* ti); /** - Return the data associated with the given avltree item. + Return the data associated with the given tree item. */ const void* zix_tree_get_data(ZixTreeIter ti); @@ -95,12 +90,21 @@ zix_tree_get_data(ZixTreeIter ti); ZixTreeIter zix_tree_begin(ZixTree* t); +/** + Return an iterator the the element one past the last element in @a t. +*/ ZixTreeIter zix_tree_end(ZixTree* t); +/** + Return true iff @a i is an iterator to the end of its tree. +*/ bool zix_tree_iter_is_end(ZixTreeIter i); +/** + Return an iterator that points to the element one past @a i. +*/ ZixTreeIter zix_tree_iter_next(ZixTreeIter i); -- cgit v1.2.1