44 if (allocator ==
NULL)
115 da[k++] = dir = cmp > 0;
153 if (
x->tavl_balance == -1) {
194 if (
x->tavl_balance == +1) {
247 return p ==
NULL || *p == item ?
NULL : *p;
258 if (p ==
NULL || *p == item)
277 for (
x = y = node;;
x =
x->tavl_link[0], y = y->
tavl_link[1])
413 q = find_parent(tree, y);
424 if (
x->tavl_balance == -1) {
455 if (
x->tavl_balance == 0) {
458 x->tavl_balance = -1;
485 if (
x->tavl_balance == +1) {
516 if (
x->tavl_balance == 0) {
519 x->tavl_balance = +1;
744 new->tavl_link[dir] =
dst->tavl_link[dir];
746 new->tavl_link[!dir] =
dst;
748 dst->tavl_link[dir] =
new;
751 new->tavl_balance =
src->tavl_balance;
753 new->tavl_data =
src->tavl_data;
756 if (new->tavl_data ==
NULL)
804 if (new->tavl_count == 0)
817 if (!copy_node(
new, q, 0, p->
tavl_link[0], copy)) {
818 copy_error_recovery(rq.
tavl_link[0],
new, destroy);
842 if (!copy_node(
new, q, 1, p->
tavl_link[1], copy)) {
843 copy_error_recovery(rq.
tavl_link[0],
new, destroy);
int compare(const void *a, const void *b)
#define assert(condition)
void *(* libavl_malloc)(struct libavl_allocator *, size_t libavl_size)
void(* libavl_free)(struct libavl_allocator *, void *libavl_block)
struct tavl_node * tavl_link[2]
unsigned char tavl_tag[2]
tavl_comparison_func * tavl_compare
struct libavl_allocator * tavl_alloc
struct tavl_node * tavl_root
struct tavl_node * tavl_node
struct tavl_table * tavl_table
void * tavl_delete(struct tavl_table *tree, const void *item)
void * tavl_t_copy(struct tavl_traverser *trav, const struct tavl_traverser *src)
void tavl_t_init(struct tavl_traverser *trav, struct tavl_table *tree)
void * tavl_t_prev(struct tavl_traverser *trav)
void * tavl_t_next(struct tavl_traverser *trav)
void * tavl_t_first(struct tavl_traverser *trav, struct tavl_table *tree)
void * tavl_t_cur(struct tavl_traverser *trav)
struct libavl_allocator tavl_allocator_default
void * tavl_t_find(struct tavl_traverser *trav, struct tavl_table *tree, void *item)
void * tavl_find(const struct tavl_table *tree, const void *item)
struct tavl_table * tavl_create(tavl_comparison_func *compare, void *param, struct libavl_allocator *allocator)
void tavl_free(struct libavl_allocator *allocator, void *block)
void * tavl_insert(struct tavl_table *table, void *item)
void * tavl_malloc(struct libavl_allocator *allocator, size_t size)
void * tavl_t_replace(struct tavl_traverser *trav, void *new)
void *() tavl_assert_delete(struct tavl_table *table, void *item)
void * tavl_t_insert(struct tavl_traverser *trav, struct tavl_table *tree, void *item)
void ** tavl_probe(struct tavl_table *tree, void *item)
struct tavl_table * tavl_copy(const struct tavl_table *org, tavl_copy_func *copy, tavl_item_func *destroy, struct libavl_allocator *allocator)
void * tavl_t_last(struct tavl_traverser *trav, struct tavl_table *tree)
void() tavl_assert_insert(struct tavl_table *table, void *item)
void * tavl_replace(struct tavl_table *table, void *item)
void tavl_destroy(struct tavl_table *tree, tavl_item_func *destroy)
void tavl_item_func(void *tavl_item, void *tavl_param)
int tavl_comparison_func(const void *tavl_a, const void *tavl_b, void *tavl_param)
void * tavl_copy_func(void *tavl_item, void *tavl_param)