|
|
|
@ -88,7 +88,7 @@ static void redblack_insert(usrtc_t *us, usrtc_node_t *node, const void *key)
|
|
|
|
|
usrtc_tree_rotate_right(parent, grandpa);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else { /*ooh,parent == parent->parent->right*/
|
|
|
|
|
} else { /* parent == parent->parent->right */
|
|
|
|
|
usrtc_node_t *uncle = grandpa->left;
|
|
|
|
|
if(uncle->color == usrtc_red) {
|
|
|
|
|
parent->color = usrtc_black;
|
|
|
|
@ -151,7 +151,8 @@ static void redblack_delete(usrtc_t *us,usrtc_node_t *node)
|
|
|
|
|
if(sister == tree_null_priv(us))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(sister->left->color==usrtc_black && sister->right->color==usrtc_black) {
|
|
|
|
|
if((sister->left->color == usrtc_black) &&
|
|
|
|
|
(sister->right->color == usrtc_black)) {
|
|
|
|
|
sister->color = usrtc_red;
|
|
|
|
|
child = parent;
|
|
|
|
|
} else {
|
|
|
|
@ -191,7 +192,8 @@ static void redblack_delete(usrtc_t *us,usrtc_node_t *node)
|
|
|
|
|
if(sister == tree_null_priv(us))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(sister->right->color==usrtc_black && sister->left->color==usrtc_black) {
|
|
|
|
|
if((sister->right->color == usrtc_black) &&
|
|
|
|
|
(sister->left->color == usrtc_black)) {
|
|
|
|
|
sister->color = usrtc_red;
|
|
|
|
|
child = parent;
|
|
|
|
|
} else {
|
|
|
|
@ -219,7 +221,7 @@ static void redblack_delete(usrtc_t *us,usrtc_node_t *node)
|
|
|
|
|
child->color = usrtc_black;
|
|
|
|
|
tree_root_priv(us)->color = usrtc_black;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void redblack_convert_from_list(usrtc_t *us)
|
|
|
|
@ -236,10 +238,10 @@ static void redblack_convert_from_list(usrtc_t *us)
|
|
|
|
|
unsigned int level = 0;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
if(usrtc_red!=0 && usrtc_black!=1)
|
|
|
|
|
if((usrtc_red!=0) && (usrtc_black != 1))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
while(fullcount>=nodecount && fullcount) /*calc*/
|
|
|
|
|
while((fullcount >= nodecount) && fullcount) /*calc*/
|
|
|
|
|
fullcount >>= 1;
|
|
|
|
|
|
|
|
|
|
botrowcount = nodecount-fullcount;
|
|
|
|
@ -247,7 +249,7 @@ static void redblack_convert_from_list(usrtc_t *us)
|
|
|
|
|
for(curr = nil->next; curr!=nil; curr=next) {
|
|
|
|
|
next=curr->next;
|
|
|
|
|
|
|
|
|
|
if(complete==NULL && botrowcount--==0) {
|
|
|
|
|
if((complete == NULL) && (botrowcount-- == 0)) {
|
|
|
|
|
baselevel = level = 1;
|
|
|
|
|
complete = tree[0];
|
|
|
|
|
|
|
|
|
@ -305,5 +307,6 @@ static void redblack_convert_from_list(usrtc_t *us)
|
|
|
|
|
complete->parent = nil;
|
|
|
|
|
complete->color = usrtc_black;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|