diff options
author | David Robillard <d@drobilla.net> | 2011-09-28 19:57:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-09-28 19:57:19 +0000 |
commit | 038314368968b7955d9a9b82b95cf51b983e2ccc (patch) | |
tree | 262984de4f4bed601fd679386324365aa5484251 /zix/tree.h | |
parent | 0e3ef580b5d265ee59d50d35053e989b8c4277c2 (diff) | |
download | zix-038314368968b7955d9a9b82b95cf51b983e2ccc.tar.gz zix-038314368968b7955d9a9b82b95cf51b983e2ccc.tar.bz2 zix-038314368968b7955d9a9b82b95cf51b983e2ccc.zip |
More glib like interface for ZixTree.
Move ZixTree debug stuff to tree_debug.h.
Support reverse iteration over ZixTree.
git-svn-id: http://svn.drobilla.net/zix/trunk@40 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
Diffstat (limited to 'zix/tree.h')
-rw-r--r-- | zix/tree.h | 53 |
1 files changed, 36 insertions, 17 deletions
@@ -38,14 +38,9 @@ extern "C" { typedef struct ZixTreeImpl ZixTree; /** - A node in a @ref ZixTree. -*/ -typedef struct ZixTreeNodeImpl ZixTreeNode; - -/** An iterator over a @ref ZixTree. */ -typedef ZixTreeNode* ZixTreeIter; +typedef struct ZixTreeNodeImpl ZixTreeIter; /** Create a new (empty) tree. @@ -63,50 +58,74 @@ zix_tree_free(ZixTree* t); Insert the element @a e into @a t and point @a ti at the new element. */ ZixStatus -zix_tree_insert(ZixTree* t, const void* e, ZixTreeIter* ti); +zix_tree_insert(ZixTree* t, void* e, ZixTreeIter** ti); /** Remove the item pointed at by @a ti from @a t. */ ZixStatus -zix_tree_remove(ZixTree* t, ZixTreeIter ti); +zix_tree_remove(ZixTree* t, ZixTreeIter* ti); /** - Set @a ti to be the largest element <= @a e in @a t. + Set @a ti to an element equal to @a e in @a t. If no such item exists, @a ti is set to NULL. */ ZixStatus -zix_tree_find(const ZixTree* t, const void* e, ZixTreeIter* ti); +zix_tree_find(const ZixTree* t, const void* e, ZixTreeIter** ti); /** Return the data associated with the given tree item. */ -const void* -zix_tree_get_data(ZixTreeIter ti); +void* +zix_tree_get(ZixTreeIter* ti); /** Return an iterator to the first (smallest) element in @a t. */ -ZixTreeIter +ZixTreeIter* zix_tree_begin(ZixTree* t); /** Return an iterator the the element one past the last element in @a t. */ -ZixTreeIter +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); +zix_tree_iter_is_end(ZixTreeIter* i); + +/** + Return an iterator to the last (largest) element in @a t. +*/ +ZixTreeIter* +zix_tree_rbegin(ZixTree* t); + +/** + Return an iterator the the element one before the first element in @a t. +*/ +ZixTreeIter* +zix_tree_rend(ZixTree* t); + +/** + Return true iff @a i is an iterator to the reverse end of its tree. +*/ +bool +zix_tree_iter_is_rend(ZixTreeIter* i); /** Return an iterator that points to the element one past @a i. */ -ZixTreeIter -zix_tree_iter_next(ZixTreeIter i); +ZixTreeIter* +zix_tree_iter_next(ZixTreeIter* i); + +/** + Return an iterator that points to the element one before @a i. +*/ +ZixTreeIter* +zix_tree_iter_prev(ZixTreeIter* i); /** @} |