summaryrefslogtreecommitdiffstats
path: root/include/zix/btree.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-11-02 16:30:44 -0400
committerDavid Robillard <d@drobilla.net>2022-11-02 17:31:55 -0400
commitdedf8b645ad676e7947c83f320198d43f4341570 (patch)
treed0bb9cf6033437020e8e75aa8f7d6bbe8b4b51c0 /include/zix/btree.h
parent4f454ff117cac82c4ce86fc22d37fd317e925a18 (diff)
downloadzix-dedf8b645ad676e7947c83f320198d43f4341570.tar.gz
zix-dedf8b645ad676e7947c83f320198d43f4341570.tar.bz2
zix-dedf8b645ad676e7947c83f320198d43f4341570.zip
Remove function_types.h
Diffstat (limited to 'include/zix/btree.h')
-rw-r--r--include/zix/btree.h38
1 files changed, 23 insertions, 15 deletions
diff --git a/include/zix/btree.h b/include/zix/btree.h
index 05b520e..f3b365a 100644
--- a/include/zix/btree.h
+++ b/include/zix/btree.h
@@ -6,7 +6,6 @@
#include "zix/allocator.h"
#include "zix/attributes.h"
-#include "zix/function_types.h"
#include "zix/status.h"
#include <stdbool.h>
@@ -40,6 +39,15 @@ typedef struct ZixBTreeImpl ZixBTree;
/// A B-Tree node (opaque)
typedef struct ZixBTreeNodeImpl ZixBTreeNode;
+/// Function for comparing two B-Tree elements
+typedef int (*ZixBTreeCompareFunc)(const void* ZIX_UNSPECIFIED a,
+ const void* ZIX_UNSPECIFIED b,
+ const void* ZIX_UNSPECIFIED user_data);
+
+/// Function to destroy a B-Tree element
+typedef void (*ZixBTreeDestroyFunc)(void* ZIX_UNSPECIFIED ptr,
+ const void* ZIX_UNSPECIFIED user_data);
+
/**
An iterator over a B-Tree.
@@ -72,9 +80,9 @@ static const ZixBTreeIter zix_btree_end_iter = {
*/
ZIX_API
ZixBTree* ZIX_ALLOCATED
-zix_btree_new(ZixAllocator* ZIX_NULLABLE allocator,
- ZixCompareFunc ZIX_NONNULL cmp,
- const void* ZIX_NULLABLE cmp_data);
+zix_btree_new(ZixAllocator* ZIX_NULLABLE allocator,
+ ZixBTreeCompareFunc ZIX_NONNULL cmp,
+ const void* ZIX_UNSPECIFIED cmp_data);
/**
Free `t` and all the nodes it contains.
@@ -88,9 +96,9 @@ zix_btree_new(ZixAllocator* ZIX_NULLABLE allocator,
*/
ZIX_API
void
-zix_btree_free(ZixBTree* ZIX_NULLABLE t,
- ZixDestroyFunc ZIX_NULLABLE destroy,
- const void* ZIX_NULLABLE destroy_user_data);
+zix_btree_free(ZixBTree* ZIX_NULLABLE t,
+ ZixBTreeDestroyFunc ZIX_NULLABLE destroy,
+ const void* ZIX_NULLABLE destroy_user_data);
/**
Clear everything from `t`, leaving it empty.
@@ -104,9 +112,9 @@ zix_btree_free(ZixBTree* ZIX_NULLABLE t,
*/
ZIX_API
void
-zix_btree_clear(ZixBTree* ZIX_NONNULL t,
- ZixDestroyFunc ZIX_NULLABLE destroy,
- const void* ZIX_NULLABLE destroy_user_data);
+zix_btree_clear(ZixBTree* ZIX_NONNULL t,
+ ZixBTreeDestroyFunc ZIX_NULLABLE destroy,
+ const void* ZIX_NULLABLE destroy_user_data);
/// Return the number of elements in `t`
ZIX_PURE_API
@@ -164,11 +172,11 @@ zix_btree_find(const ZixBTree* ZIX_NONNULL t,
*/
ZIX_API
ZixStatus
-zix_btree_lower_bound(const ZixBTree* ZIX_NONNULL t,
- ZixCompareFunc ZIX_NULLABLE compare_key,
- const void* ZIX_NULLABLE compare_key_user_data,
- const void* ZIX_UNSPECIFIED key,
- ZixBTreeIter* ZIX_NONNULL ti);
+zix_btree_lower_bound(const ZixBTree* ZIX_NONNULL t,
+ ZixBTreeCompareFunc ZIX_NULLABLE compare_key,
+ const void* ZIX_NULLABLE compare_key_user_data,
+ const void* ZIX_UNSPECIFIED key,
+ ZixBTreeIter* ZIX_NONNULL ti);
/// Return the data at the given position in the tree
ZIX_PURE_API