16 return *(
const int *)tval - *(
const int *)search;
22 printf(
"now free %d at %p\n", *(
int*)data, data);
29 Tree node = (Tree)_node;
30 int value = *(
int *)node->data;
33 for (i=1; i<7; i++) i<=depth?printf(
"-"):printf(
" ");
34 printf(
"%p:%d p:%p l:%p r:%p\n",
35 node, value, node->parent, node->left, node->right);
57 main(
int argc,
char * argv[])
83 printf(
"insert %p(%d) got %p(%d)\n", element, *element, found, *found);
84 if (found != element) {
85 printf(
"remove duplicate");
94 printf(
"can't find segmenet of minimum size: %d\n", 10);
96 printf(
"found %d\n", *found);
102 printf(
"can't find segmenet of minimum size: %d\n", 64);
104 printf(
"found %d\n", *found);
110 printf(
"can't find segmenet of minimum size: %d\n", 70);
112 printf(
"found %d\n", *found);
117 printf(
"delete %p(%d) got %p(%d)\n", &search70, search70, found, *found);
124 printf(
"insert %p(%d) got %p(%d)\n", &search80, search80, found, *found);
126 printf(
"insert %p(%d) got %p(%d)\n", &search50, search50, found, *found);
128 printf(
"insert %p(%d) got %p(%d)\n", &search80, search80, found, *found);
135 printf(
"delete %p(%d) got %p(%d)\n", &search80, search80, found, *found);
142 printf(
"delete %p(%d) got %p(%d)\n", &search50, search50, found, *found);
149 printf(
"delete %p(%d) got %p(%d)\n", &search70, search70, found, found?*found:-1);
157 printf(
"delete %p(%d) got %p(%d)\n",
162 if (found != element) {
void printNode(const void *_node, const int depth)
int main(int argc, char *argv[])
void * treeInsert(Tree *, const void *, TreeComp)
void freeNode(const void *data, const int depth)
int insertCompare(const void *tval, const void *search)
void * treeFind(Tree, const void *, TreeComp)
void * treeDelete(Tree *, const void *, TreeComp)
void treeWalk(Tree, TreeAction)
void treeDestroy(Tree *, TreeAction)