37 int (*
cmp)(
void *key,
const void *
b),
void *next[2])
40 unsigned int v =
cmp(key, t->
elem);
43 next[v >> 31] = t->
elem;
61 unsigned int v =
cmp(t->
elem, key);
70 key = t->
elem = next_elem[i];
80 int i = (v >> 31) ^ !!*next;
82 t->
state += 2 * i - 1;
84 if (!(t->
state & 1)) {
106 if ((*child)->state * 2 == -t->
state) {
107 *tp = (*child)->
child[i ^ 1];
110 *child = (*tp)->
child[i ^ 1];
111 (*tp)->
child[i ^ 1] = t;
114 (*tp)->child[1]->state = (*tp)->state < 0;
118 *child = (*child)->
child[i ^ 1];
119 (*tp)->
child[i ^ 1] = t;
124 (*tp)->state = -t->
state;
128 if (!(*tp)->state ^ !!*next)
153 int (*
cmp)(
void *opaque,
void *
elem),
154 int (*enu)(
void *opaque,
void *elem))
161 enu(opaque, t->
elem);
memory handling functions
struct AVTreeNode * av_tree_node_alloc(void)
Allocate an AVTreeNode.
void * av_tree_find(const AVTreeNode *t, void *key, int(*cmp)(void *key, const void *b), void *next[2])
static int cmp(void *a, const void *b)
void av_tree_destroy(AVTreeNode *t)
void * av_tree_insert(AVTreeNode **tp, void *key, int(*cmp)(void *key, const void *b), AVTreeNode **next)
Insert or remove an element.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
struct AVTreeNode * child[2]
void av_tree_enumerate(AVTreeNode *t, void *opaque, int(*cmp)(void *opaque, void *elem), int(*enu)(void *opaque, void *elem))
Apply enu(opaque, &elem) to all the elements in the tree in a given range.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...