2.4.1.2 Setup

void zix_btree_clear(ZixBTree *t, ZixBTreeDestroyFunc destroy, const void *destroy_data)

Clear everything from t, leaving it empty.

Parameters:
  • t – The tree to clear.

  • destroy – Function called exactly once for every value in the tree, just before that value is removed from the tree.

  • destroy_data – Opaque user data pointer to pass to destroy.

void zix_btree_free(ZixBTree *t, ZixBTreeDestroyFunc destroy, const void *destroy_data)

Free t and all the nodes it contains.

Parameters:
  • t – The tree to free.

  • destroy – Function to call once for every value in the tree. This can be used to free values if they are dynamically allocated.

  • destroy_data – Opaque user data pointer to pass to destroy.

ZixBTree *zix_btree_new(ZixAllocator *allocator, ZixBTreeCompareFunc cmp, const void *cmp_data)

Create a new (empty) B-Tree.

The given comparator must be a total ordering and is used to internally organize the tree and look for values exactly.

Searching can be done with a custom comparator that supports wildcards, see zix_btree_lower_bound() for details.

size_t zix_btree_size(const ZixBTree *t)

Return the number of elements in t.