1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include <assert.h>
- #include "private.h"
- void
- lub_bintree_remove(lub_bintree_t *this,
- void *clientnode)
- {
- lub_bintree_node_t *x,*t;
- lub_bintree_key_t key;
- int comp;
-
- this->getkeyFn(clientnode,&key);
-
- t = lub_bintree_splay(this,this->root,&key);
-
- comp = lub_bintree_compare(this,t,&key);
- assert(0 == comp);
- if(0 == comp)
- {
- if (t->left == NULL)
- {
- x = t->right;
- }
- else
- {
- x = lub_bintree_splay(this,t->left,&key);
- x->right = t->right;
- }
-
- this->root = x;
-
- lub_bintree_node_init(lub_bintree_getnode(this,clientnode));
- }
- }
|