51 assert (compare != NULL);
53 if (allocator == NULL)
77 assert (tree != NULL && item != NULL);
78 for (p = tree->
avl_root; p != NULL; )
109 assert (tree != NULL && item != NULL);
114 for (q = z, p = y; p != NULL; q = p, p = p->
avl_link[dir])
120 if (p->avl_balance != 0)
122 da[k++] = dir = cmp > 0;
137 for (p = y, k = 0; p != n; p = p->
avl_link[da[k]], k++)
213 return p == NULL || *p == item ? NULL : *p;
224 if (p == NULL || *p == item)
247 assert (tree != NULL && item != NULL);
251 for (cmp = -1; cmp != 0;
400 return (
void *) item;
408 assert (trav != NULL);
450 assert (tree != NULL && trav != NULL);
466 return x != NULL ? x->
avl_data : NULL;
477 assert (tree != NULL && trav != NULL);
493 return x != NULL ? x->
avl_data : NULL;
506 assert (trav != NULL && tree != NULL && item != NULL);
510 for (p = tree->
avl_root; p != NULL; p = q)
545 assert (trav != NULL && tree != NULL && item != NULL);
568 assert (trav != NULL && src != NULL);
594 assert (trav != NULL);
647 assert (trav != NULL);
696 assert (trav != NULL);
709 assert (trav != NULL && trav->
avl_node != NULL &&
new != NULL);
719 copy_error_recovery (
struct avl_node **stack,
int height,
722 assert (stack != NULL && height >= 0 &&
new != NULL);
724 for (; height > 2; height -= 2)
725 stack[height - 1]->
avl_link[1] = NULL;
749 assert (org != NULL);
751 allocator != NULL ? allocator : org->
avl_alloc);
755 if (new->avl_count == 0)
759 y = (
struct avl_node *) &
new->avl_root;
767 new->avl_alloc->libavl_malloc (new->avl_alloc,
771 if (y != (
struct avl_node *) &new->avl_root)
777 copy_error_recovery (stack, height,
new, destroy);
781 stack[height++] = (
struct avl_node *) x;
799 copy_error_recovery (stack, height,
new, destroy);
807 new->avl_alloc->libavl_malloc (new->avl_alloc,
811 copy_error_recovery (stack, height,
new, destroy);
838 assert (tree != NULL);
840 for (p = tree->
avl_root; p != NULL; p = q)
844 if (destroy != NULL && p->
avl_data != NULL)
863 assert (allocator != NULL && size > 0);
864 return malloc (size);
871 assert (allocator != NULL && block != NULL);
890 assert (p != NULL && *p == item);
struct avl_table * avl_copy(const struct avl_table *org, avl_copy_func *copy, avl_item_func *destroy, struct libavl_allocator *allocator)
void avl_destroy(struct avl_table *tree, avl_item_func *destroy)
void avl_item_func(void *avl_item, void *avl_param)
void * avl_delete(struct avl_table *tree, const void *item)
void * avl_t_next(struct avl_traverser *trav)
struct avl_node * avl_node
void *() avl_assert_delete(struct avl_table *table, void *item)
unsigned long avl_generation
struct avl_table * avl_create(avl_comparison_func *compare, void *param, struct libavl_allocator *allocator)
void * avl_t_insert(struct avl_traverser *trav, struct avl_table *tree, void *item)
struct avl_node * avl_link[2]
void() avl_assert_insert(struct avl_table *table, void *item)
unsigned long avl_generation
void avl_free(struct libavl_allocator *allocator, void *block)
void * avl_copy_func(void *avl_item, void *avl_param)
void * avl_insert(struct avl_table *table, void *item)
void * avl_t_find(struct avl_traverser *trav, struct avl_table *tree, void *item)
void * avl_t_prev(struct avl_traverser *trav)
void * avl_find(const struct avl_table *tree, const void *item)
void *(* libavl_malloc)(struct libavl_allocator *, size_t libavl_size)
void * avl_t_cur(struct avl_traverser *trav)
struct avl_node * avl_stack[AVL_MAX_HEIGHT]
void * avl_t_replace(struct avl_traverser *trav, void *new)
int avl_comparison_func(const void *avl_a, const void *avl_b, void *avl_param)
void ** avl_probe(struct avl_table *tree, void *item)
struct avl_node * avl_root
struct libavl_allocator avl_allocator_default
void * avl_t_copy(struct avl_traverser *trav, const struct avl_traverser *src)
void(* libavl_free)(struct libavl_allocator *, void *libavl_block)
void * avl_replace(struct avl_table *table, void *item)
void * avl_t_first(struct avl_traverser *trav, struct avl_table *tree)
avl_comparison_func * avl_compare
struct libavl_allocator * avl_alloc
void * avl_malloc(struct libavl_allocator *allocator, size_t size)
void avl_t_init(struct avl_traverser *trav, struct avl_table *tree)
struct avl_table * avl_table
void * avl_t_last(struct avl_traverser *trav, struct avl_table *tree)