summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tree.c6
-rw-r--r--zix/common.h5
-rw-r--r--zix/tree.h22
3 files changed, 21 insertions, 12 deletions
diff --git a/src/tree.c b/src/tree.c
index aa99399..c0638f6 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -451,7 +451,7 @@ zix_tree_rebalance(ZixTree* t, ZixTreeNode* node, int* height_change)
}
ZIX_API
-int
+ZixStatus
zix_tree_insert(ZixTree* t, const void* e, ZixTreeIter* ti)
{
#ifdef ZIX_TREE_DUMP
@@ -549,7 +549,7 @@ zix_tree_insert(ZixTree* t, const void* e, ZixTreeIter* ti)
}
ZIX_API
-int
+ZixStatus
zix_tree_remove(ZixTree* t, ZixTreeIter ti)
{
ZixTreeNode* const n = ti;
@@ -699,7 +699,7 @@ zix_tree_remove(ZixTree* t, ZixTreeIter ti)
}
ZIX_API
-int
+ZixStatus
zix_tree_find(const ZixTree* t, const void* e, ZixTreeIter* ti)
{
ZixTreeNode* n = t->root;
diff --git a/zix/common.h b/zix/common.h
index dd86a8b..ee18664 100644
--- a/zix/common.h
+++ b/zix/common.h
@@ -48,6 +48,11 @@ typedef enum {
} 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
@@ -33,11 +33,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.
*/
typedef struct ZixTreeImpl ZixTree;
@@ -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);