45 if (allocator ==
NULL)
112 da[k++] = dir = cmp > 0;
144 if (
x->avl_balance == -1) {
169 if (
x->avl_balance == +1) {
206 return p ==
NULL || *p == item ?
NULL : *p;
217 if (p ==
NULL || *p == item)
270 if (
r->avl_link[0] ==
NULL) {
315 if (
x->avl_balance == -1) {
337 if (
x->avl_balance == 0) {
354 if (
x->avl_balance == +1) {
376 if (
x->avl_balance == 0) {
444 while (
x->avl_link[0] !=
NULL) {
469 while (
x->avl_link[1] !=
NULL) {
580 else if (
x->avl_link[1] !=
NULL) {
585 while (
x->avl_link[0] !=
NULL) {
602 }
while (y ==
x->avl_link[1]);
625 else if (
x->avl_link[0] !=
NULL) {
630 while (
x->avl_link[1] !=
NULL) {
647 }
while (y ==
x->avl_link[0]);
679 static void copy_error_recovery(
struct avl_node **stack,
int height,
684 for (; height > 2; height -= 2)
716 if (new->avl_count == 0)
720 y = (
struct avl_node *)&
new->avl_root;
722 while (
x->avl_link[0] !=
NULL) {
725 y->
avl_link[0] =
new->avl_alloc->libavl_malloc(
726 new->avl_alloc,
sizeof *y->
avl_link[0]);
728 if (y != (
struct avl_node *)&new->avl_root) {
733 copy_error_recovery(stack, height,
new, destroy);
752 copy_error_recovery(stack, height,
new, destroy);
757 if (
x->avl_link[1] !=
NULL) {
758 y->
avl_link[1] =
new->avl_alloc->libavl_malloc(
759 new->avl_alloc,
sizeof *y->
avl_link[1]);
761 copy_error_recovery(stack, height,
new, destroy);
void * avl_t_prev(struct avl_traverser *trav)
void * avl_t_insert(struct avl_traverser *trav, struct avl_table *tree, void *item)
void *() avl_assert_delete(struct avl_table *table, void *item)
void * avl_find(const struct avl_table *tree, const void *item)
void * avl_t_replace(struct avl_traverser *trav, void *new)
void * avl_t_copy(struct avl_traverser *trav, const struct avl_traverser *src)
void * avl_t_last(struct avl_traverser *trav, struct avl_table *tree)
void * avl_t_cur(struct avl_traverser *trav)
void * avl_delete(struct avl_table *tree, const void *item)
void() avl_assert_insert(struct avl_table *table, void *item)
struct libavl_allocator avl_allocator_default
void * avl_t_next(struct avl_traverser *trav)
void * avl_t_first(struct avl_traverser *trav, struct avl_table *tree)
void * avl_malloc(struct libavl_allocator *allocator, size_t size)
struct avl_table * avl_create(avl_comparison_func *compare, void *param, struct libavl_allocator *allocator)
void * avl_t_find(struct avl_traverser *trav, struct avl_table *tree, void *item)
void ** avl_probe(struct avl_table *tree, void *item)
void avl_t_init(struct avl_traverser *trav, struct avl_table *tree)
void avl_free(struct libavl_allocator *allocator, void *block)
struct avl_table * avl_copy(const struct avl_table *org, avl_copy_func *copy, avl_item_func *destroy, struct libavl_allocator *allocator)
void * avl_insert(struct avl_table *table, void *item)
void * avl_replace(struct avl_table *table, void *item)
void avl_destroy(struct avl_table *tree, avl_item_func *destroy)
void * avl_copy_func(void *avl_item, void *avl_param)
void avl_item_func(void *avl_item, void *avl_param)
int avl_comparison_func(const void *avl_a, const void *avl_b, void *avl_param)
int compare(const void *a, const void *b)
#define assert(condition)
struct avl_node * avl_link[2]
avl_comparison_func * avl_compare
struct libavl_allocator * avl_alloc
unsigned long avl_generation
struct avl_node * avl_root
unsigned long avl_generation
struct avl_node * avl_stack[AVL_MAX_HEIGHT]
struct avl_table * avl_table
struct avl_node * avl_node
void *(* libavl_malloc)(struct libavl_allocator *, size_t libavl_size)
void(* libavl_free)(struct libavl_allocator *, void *libavl_block)