Mercurial > hg > Members > Moririn
view src/parallel_execution/rb_tree.c @ 139:c13b07d15d86
fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 09 Nov 2016 10:13:31 +0900 |
parents | 04a2f486a30d |
children | f31b4e4bf4bb |
line wrap: on
line source
#include <stdio.h> #include "context.h" #include "origin_cs.h" extern enum Relational compare(struct Node* node1, struct Node* node2); void printTree1(union Data* data) { struct Node* node = &data->node; if (node == NULL) { printf("NULL"); } else { printf("key = %d (", node->key); printTree1((union Data*)(node->right)); printf("), ("); printTree1((union Data*)(node->left)); printf(")"); } } void printTree(union Data* data) { printTree1(data); printf("\n"); } __code put(struct Context* context, struct Stack* nodeStack, struct Tree* tree, struct Node* node, struct Traverse* traverse, struct Node* root, struct Node* newNode) { printTree((union Data*)(tree->root)); traverse->newNode = newNode; tree->root = newNode; // this should done at stackClear if (root) { traverse->current = root; traverse->result = compare(traverse->current, node); goto meta(context, Replace); } goto meta(context, Insert); } __code put_stub(struct Context* context) { struct Node* newNode = &ALLOCATE(context, Node)->node; goto put(context, &context->data[Stack]->stack, &context->data[Tree]->tree, &context->data[Node]->node, &context->data[Traverse]->traverse, context->data[Tree]->tree.root, newNode ); } __code replaceNode(struct Context* context, struct Traverse* traverse, struct Node* oldNode, struct Node* newNode, struct Stack* nodeStack) { traverse->previous = newNode; *newNode = *oldNode; nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->data = (union Data*)(newNode); nodeStack->next = Replace1; goto meta(context, traverse->nodeStack->push); } __code replaceNode_stub(struct Context* context) { goto replaceNode(context, &context->data[Traverse]->traverse, context->data[Traverse]->traverse.current, context->data[Traverse]->traverse.newNode, &context->data[Stack]->stack); } __code replaceNode1(struct Context* context, struct Traverse* traverse, struct Node* node, struct Node* oldNode, struct Node* newNode, struct Node* newnewNode, int result) { if (result == EQ) { newNode->value = node->value; // go to stack clear goto meta(context, context->next); } else if (result == GT) { traverse->current = oldNode->right; newNode->right = newnewNode; } else { traverse->current = oldNode->left; newNode->left = newnewNode; } traverse->newNode = newnewNode; if (traverse->current) { traverse->result = compare(traverse->current, node); goto meta(context, Replace); } goto meta(context, Insert); } __code replaceNode1_stub(struct Context* context) { struct Node* newnewNode = &ALLOCATE(context, Node)->node; goto replaceNode1(context, &context->data[Traverse]->traverse, &context->data[Node]->node, context->data[Traverse]->traverse.current, context->data[Traverse]->traverse.previous, newnewNode, context->data[Traverse]->traverse.result); } __code insertNode(struct Context* context, struct Traverse* traverse, struct Node* node, struct Node* newNode) { *newNode = *node; newNode->color = Red; traverse->current = newNode; goto meta(context, InsertCase1); } __code insertNode_stub(struct Context* context) { goto insertNode(context, &context->data[Traverse]->traverse, &context->data[Node]->node, context->data[Traverse]->traverse.newNode); } __code insertCase1(struct Context* context,struct Traverse* traverse, struct Tree* tree, struct Stack* nodeStack) { struct SingleLinkedStack* stack = (struct SingleLinkedStack*)traverse->nodeStack->stack; if (stack->top != NULL) { nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = InsertCase2; goto meta(context, traverse->nodeStack->get); } tree->root->color = Black; goto meta(context, StackClear); } __code insert1_stub(struct Context* context) { goto insertCase1(context, &context->data[Traverse]->traverse, &context->data[Tree]->tree, &context->data[Stack]->stack); } __code insertCase2(struct Context* context, struct Traverse* traverse, struct Stack* nodeStack, struct Node* parent) { if (parent->color == Black) { goto meta(context, StackClear); } nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = InsertCase3; goto meta(context, traverse->nodeStack->get2); } __code insert2_stub(struct Context* context) { struct SingleLinkedStack *nodeStack = (struct SingleLinkedStack*)context->data[Traverse]->traverse.nodeStack->stack; goto insertCase2(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack, &nodeStack->top->data->node); } __code insertCase3(struct Context* context, struct Traverse* traverse, struct Stack* nodeStack, struct Node* parent, struct Node* grandparent) { struct Node* uncle; if (grandparent->left == parent) uncle = grandparent->right; else uncle = grandparent->left; if (uncle && (uncle->color == Red)) { // do insertcase1 on grandparent, stack must be pop by two parent->color = Black; uncle->color = Black; grandparent->color = Red; traverse->current = grandparent; nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = InsertCase1; goto meta(context, traverse->nodeStack->pop2); } nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = InsertCase4; goto meta(context, traverse->nodeStack->get2); } __code insert3_stub(struct Context* context) { goto insertCase3(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack, &context->data[Traverse]->traverse.nodeStack->data->node, &context->data[Traverse]->traverse.nodeStack->data1->node ); } __code insertCase4(struct Context* context, struct Traverse* traverse, struct Node* current,struct Node* parent, struct Node* grandparent) { struct Stack* nodeStack = traverse->nodeStack; traverse->current = parent; if ((current == parent->right) && (parent == grandparent->left)) { traverse->current = traverse->current->left; traverse->rotateNext = InsertCase5; nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = RotateL; goto meta(context, nodeStack->pop); } else if ((current == parent->left) && (parent == grandparent->right)) { traverse->current = traverse->current->right; traverse->rotateNext = InsertCase5; nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = RotateR; goto meta(context, nodeStack->pop); } traverse->current = current; goto meta(context, InsertCase5); } __code insert4_stub(struct Context* context) { goto insertCase4(context, &context->data[Traverse]->traverse, context->data[Traverse]->traverse.current, &context->data[Traverse]->traverse.nodeStack->data->node, &context->data[Traverse]->traverse.nodeStack->data1->node); } __code insertCase5(struct Context* context, struct Traverse* traverse) { struct Stack* nodeStack = traverse->nodeStack; nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = InsertCase51; goto meta(context, nodeStack->get2); } __code insert5_stub(struct Context* context) { goto insertCase5(context, &context->data[Traverse]->traverse); } __code insertCase51(struct Context* context, struct Traverse* traverse, struct Node* current, struct Node* parent, struct Node* grandparent) { parent->color = Black; grandparent->color = Red; traverse->current = grandparent; traverse->rotateNext = StackClear; if ((current == parent->left) && (parent == grandparent->left)) goto meta(context, RotateR); else goto meta(context, RotateL); } __code insert51_stub(struct Context* context) { struct Traverse* traverse = &context->data[Traverse]->traverse; struct Node* parent = &traverse->nodeStack->data->node; struct Node* grandparent = &traverse->nodeStack->data1->node; goto insertCase51(context, &context->data[Traverse]->traverse, context->data[Traverse]->traverse.current, parent, grandparent); } // put rotateLeft's continuation as argument __code rotateLeft(struct Context* context, struct Traverse* traverse) { struct Stack* nodeStack = traverse->nodeStack; nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = RotateL1; goto meta(context, nodeStack->get); } __code rotateLeft_stub(struct Context* context) { goto rotateLeft(context, &context->data[Traverse]->traverse); } __code rotateLeft1(struct Context* context, struct Node* node, struct Tree* tree, struct Traverse* traverse, struct Node* parent) { struct Node* tmp = node->right; if (parent) { if (node == parent->left) parent->left = tmp; else parent->right = tmp; } else { tree->root = tmp; } node->right = tmp->left; tmp->left = node; traverse->current = tmp; goto meta(context, traverse->rotateNext); } __code rotateLeft1_stub(struct Context* context) { struct Traverse* traverse = &context->data[Traverse]->traverse; struct Node* parent = &traverse->nodeStack->data->node; goto rotateLeft1(context, context->data[Traverse]->traverse.current, &context->data[Tree]->tree, &context->data[Traverse]->traverse, parent); } __code rotateRight(struct Context* context, struct Traverse* traverse) { struct Stack* nodeStack = traverse->nodeStack; nodeStack->next = RotateR1; goto meta(context, nodeStack->get); } __code rotateRight_stub(struct Context* context) { goto rotateRight(context, &context->data[Traverse]->traverse); } __code rotateRight1(struct Context* context, struct Node* node, struct Tree* tree, struct Traverse* traverse, struct Node* parent) { struct Node* tmp = node->left; if (parent) { if (node == parent->left) parent->left = tmp; else parent->right = tmp; } else { tree->root = tmp; } node->left = tmp->right; tmp->right = node; traverse->current = tmp; goto meta(context, traverse->rotateNext); } __code rotateRight1_stub(struct Context* context) { struct Traverse* traverse = &context->data[Traverse]->traverse; struct Node* parent = &traverse->nodeStack->data->node; goto rotateRight1(context, context->data[Traverse]->traverse.current, &context->data[Tree]->tree, &context->data[Traverse]->traverse, parent); } __code stackClear(struct Context* context, struct Traverse* traverse) { traverse->current = 0; struct SingleLinkedStack* nodeStack = &context->data[Traverse]->traverse.nodeStack->stack->singleLinkedStack; nodeStack->top = NULL; goto meta(context, context->next); } __code stackClear_stub(struct Context* context) { goto stackClear(context, &context->data[Traverse]->traverse); } __code get(struct Context* context, struct Tree* tree, struct Traverse* traverse) { if (tree->root) { traverse->current = tree->root; goto meta(context, Search); } goto meta(context, traverse->next); } __code get_stub(struct Context* context) { goto get(context, &context->data[Tree]->tree, &context->data[Traverse]->traverse); } __code search(struct Context* context, struct Traverse* traverse, struct Node* node) { // compare(context, traverse, traverse->current->key, node->key); traverse->result = compare(traverse->current, node); if (traverse->result == EQ) { *node = *traverse->current; goto meta(context, traverse->next); } else if (traverse->result == GT) { traverse->current = traverse->current->right; } else { traverse->current = traverse->current->left; } if (traverse->current) goto meta(context, Search); goto meta(context, traverse->next); } __code search_stub(struct Context* context) { goto search(context, &context->data[Traverse]->traverse, &context->data[Node]->node); } /* /\* __code delete(struct Context* context, struct Tree* tree) { *\/ */ /* /\* if (tree->root) { *\/ */ /* /\* stack_push(context->code_stack, &context->next); *\/ */ /* /\* context->next = Delete1; *\/ */ /* /\* goto meta(context, Get); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, context->next); *\/ */ /* /\* } *\/ */ /* /\* __code delete_stub(struct Context* context) { *\/ */ /* /\* goto delete(context, &context->data[Tree]->tree); *\/ */ /* /\* } *\/ */ /* /\* __code delete1(struct Context* context, struct Tree* tree, struct Allocate* allocate) { *\/ */ /* /\* allocate->size = sizeof(struct Node); *\/ */ /* /\* allocator(context); *\/ */ /* /\* struct Node* root = tree->root; *\/ */ /* /\* tree->root = &context->data[context->dataNum]->node; *\/ */ /* /\* tree->current = root; *\/ */ /* /\* compare(context, tree, tree->current->key, context->data[Node]->node.key); *\/ */ /* /\* goto meta(context, Replace_d1); *\/ */ /* /\* } *\/ */ /* /\* __code delete1_stub(struct Context* context) { *\/ */ /* /\* goto delete1(context, &context->data[Tree]->tree, &context->data[Allocate]->allocate); *\/ */ /* /\* } *\/ */ /* /\* __code delete2(struct Context* context, struct Node* current) { *\/ */ /* /\* if (current->color == Black) { *\/ */ /* /\* struct Node* child = current->right == NULL ? current->left : current->right; *\/ */ /* /\* current->color = child == NULL ? Black : child->color; *\/ */ /* /\* goto meta(context, DeleteCase1); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, Delete3); *\/ */ /* /\* } *\/ */ /* /\* __code delete2_stub(struct Context* context) { *\/ */ /* /\* goto delete2(context, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code delete3(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */ /* /\* struct Node* tmp = current->right == NULL ? current->left : current->right; *\/ */ /* /\* if (current->parent) { *\/ */ /* /\* if (current == current->parent->left) *\/ */ /* /\* current->parent->left = tmp; *\/ */ /* /\* else *\/ */ /* /\* current->parent->right = tmp; *\/ */ /* /\* } else { *\/ */ /* /\* tree->root = tmp; *\/ */ /* /\* } *\/ */ /* /\* if (tmp) *\/ */ /* /\* tmp->parent = current->parent; *\/ */ /* /\* if (current->parent == NULL && tmp) *\/ */ /* /\* tmp->color = Black; *\/ */ /* /\* current == current->parent->left ? (current->parent->left = NULL) : (current->parent->right = NULL); *\/ */ /* /\* stack_pop(context->code_stack, &context->next); *\/ */ /* /\* goto meta(context, context->next); *\/ */ /* /\* } *\/ */ /* /\* __code delete3_stub(struct Context* context) { *\/ */ /* /\* goto delete3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code replaceNodeForDelete1(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode, int result) { *\/ */ /* /\* *newNode = *oldNode; *\/ */ /* /\* if (result == EQ) *\/ */ /* /\* goto meta(context, Replace_d2); *\/ */ /* /\* else if (result == GT) *\/ */ /* /\* tree->current = newNode->right; *\/ */ /* /\* else *\/ */ /* /\* tree->current = newNode->left; *\/ */ /* /\* tree->current->parent = newNode; *\/ */ /* /\* if (tree->current->left == NULL && tree->current->right == NULL) *\/ */ /* /\* goto meta(context, Delete2); *\/ */ /* /\* if (result == GT) *\/ */ /* /\* newNode->right = context->heap; *\/ */ /* /\* else if (result == LT) *\/ */ /* /\* newNode->left = context->heap; *\/ */ /* /\* allocator(context); *\/ */ /* /\* compare(context, tree, tree->current->key, context->data[Node]->node.key); *\/ */ /* /\* goto meta(context, Replace_d1); *\/ */ /* /\* } *\/ */ /* /\* __code replaceNodeForDelete1_stub(struct Context* context) { *\/ */ /* /\* goto replaceNodeForDelete1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node, context->data[Tree]->tree.result); *\/ */ /* /\* } *\/ */ /* /\* __code replaceNodeForDelete2(struct Context* context, struct Tree* tree, struct Node* newNode) { *\/ */ /* /\* if (tree->current->left && tree->current->right) { *\/ */ /* /\* newNode->left->parent = newNode; *\/ */ /* /\* tree->current = newNode->left; *\/ */ /* /\* newNode->left = context->heap; *\/ */ /* /\* tree->deleted = newNode; *\/ */ /* /\* allocator(context); *\/ */ /* /\* tree->current->parent = newNode; *\/ */ /* /\* goto meta(context, FindMax1); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, Delete2); *\/ */ /* /\* } *\/ */ /* /\* __code replaceNodeForDelete2_stub(struct Context* context) { *\/ */ /* /\* goto replaceNodeForDelete2(context, &context->data[Tree]->tree, &context->data[context->dataNum]->node); *\/ */ /* /\* } *\/ */ /* /\* __code findMax1(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode) { *\/ */ /* /\* *newNode = *oldNode; *\/ */ /* /\* if (newNode->right) *\/ */ /* /\* goto meta(context, FindMax2); *\/ */ /* /\* tree->deleted->key = newNode->key; *\/ */ /* /\* tree->deleted->value = newNode->value; *\/ */ /* /\* tree->current = newNode; *\/ */ /* /\* goto meta(context, Delete2); *\/ */ /* /\* } *\/ */ /* /\* __code findMax1_stub(struct Context* context) { *\/ */ /* /\* goto findMax1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node); *\/ */ /* /\* } *\/ */ /* /\* __code findMax2(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode) { *\/ */ /* /\* *newNode = *oldNode; *\/ */ /* /\* if (newNode->right->right) { *\/ */ /* /\* tree->current = newNode->right; *\/ */ /* /\* newNode->right = context->heap; *\/ */ /* /\* allocator(context); *\/ */ /* /\* tree->current->parent = newNode; *\/ */ /* /\* goto meta(context, FindMax2); *\/ */ /* /\* } *\/ */ /* /\* tree->deleted->key = newNode->right->key; *\/ */ /* /\* tree->deleted->value = newNode->right->value; *\/ */ /* /\* tree->current = newNode; *\/ */ /* /\* goto meta(context, Delete2); *\/ */ /* /\* } *\/ */ /* /\* __code findMax2_stub(struct Context* context) { *\/ */ /* /\* goto findMax2(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase1(struct Context* context, struct Node* current) { *\/ */ /* /\* if (current->parent) *\/ */ /* /\* goto meta(context, DeleteCase2); *\/ */ /* /\* goto meta(context, Delete3); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase1_stub(struct Context* context) { *\/ */ /* /\* goto deleteCase1(context, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase2(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */ /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */ /* /\* if ((sibling == NULL ? Black : sibling->color) == Red) { *\/ */ /* /\* current->parent->color = Red; *\/ */ /* /\* sibling->color = Black; *\/ */ /* /\* current == current->parent->left ? (current->parent->left = context->heap) : (current->parent->right = context->heap); *\/ */ /* /\* allocator(context); *\/ */ /* /\* context->data[context->dataNum]->node = *sibling; *\/ */ /* /\* tree->current = current->parent; *\/ */ /* /\* context->next = DeleteCase3; *\/ */ /* /\* stack_push(context->code_stack, &context->next); *\/ */ /* /\* if (current == current->parent->left) *\/ */ /* /\* goto meta(context, RotateL); *\/ */ /* /\* else *\/ */ /* /\* goto meta(context, RotateR); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, DeleteCase3); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase2_stub(struct Context* context) { *\/ */ /* /\* goto deleteCase2(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase3(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */ /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */ /* /\* if (current->parent->color == Black && *\/ */ /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */ /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */ /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */ /* /\* sibling->color = Red; *\/ */ /* /\* tree->current = current->parent; *\/ */ /* /\* goto meta(context, DeleteCase1); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, DeleteCase4); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase3_stub(struct Context* context) { *\/ */ /* /\* goto deleteCase3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase4(struct Context* context, struct Node* current) { *\/ */ /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */ /* /\* if (current->parent->color == Red && *\/ */ /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */ /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */ /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */ /* /\* sibling->color = Red; *\/ */ /* /\* current->parent->color = Black; *\/ */ /* /\* goto meta(context, Delete3); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, DeleteCase5); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase4_stub(struct Context* context) { *\/ */ /* /\* goto deleteCase4(context, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase5(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */ /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */ /* /\* sibling->parent = current->parent; *\/ */ /* /\* if (current == current->parent->left && *\/ */ /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */ /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Red && *\/ */ /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */ /* /\* sibling->color = Red; *\/ */ /* /\* sibling->left->color = Black; *\/ */ /* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */ /* /\* allocator(context); *\/ */ /* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */ /* /\* *tmp = *sibling; *\/ */ /* /\* tmp->parent = current; *\/ */ /* /\* tmp->left = context->heap; *\/ */ /* /\* allocator(context); *\/ */ /* /\* context->data[context->dataNum]->node = *sibling->left; *\/ */ /* /\* context->data[context->dataNum]->node.parent = tmp; *\/ */ /* /\* tree->current = tmp; *\/ */ /* /\* context->next = DeleteCase6; *\/ */ /* /\* stack_push(context->code_stack, &context->next); *\/ */ /* /\* goto meta(context, RotateR); *\/ */ /* /\* } else if (current == current->parent->right && *\/ */ /* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */ /* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */ /* /\* (sibling->right == NULL ? Black : sibling->right->color) == Red) { *\/ */ /* /\* sibling->color = Red; *\/ */ /* /\* sibling->right->color = Black; *\/ */ /* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */ /* /\* allocator(context); *\/ */ /* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */ /* /\* *tmp = *sibling; *\/ */ /* /\* tmp->parent = current; *\/ */ /* /\* tmp->right = context->heap; *\/ */ /* /\* allocator(context); *\/ */ /* /\* context->data[context->dataNum]->node = *sibling->right; *\/ */ /* /\* context->data[context->dataNum]->node.parent = tmp; *\/ */ /* /\* tree->current = tmp; *\/ */ /* /\* context->next = DeleteCase6; *\/ */ /* /\* stack_push(context->code_stack, &context->next); *\/ */ /* /\* goto meta(context, RotateL); *\/ */ /* /\* } *\/ */ /* /\* goto meta(context, DeleteCase6); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase5_stub(struct Context* context) { *\/ */ /* /\* goto deleteCase5(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase6(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */ /* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */ /* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */ /* /\* allocator(context); *\/ */ /* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */ /* /\* *tmp = *sibling; *\/ */ /* /\* tmp->parent = current; *\/ */ /* /\* tmp->color = current->parent->color; *\/ */ /* /\* current->parent->color = Black; *\/ */ /* /\* context->next = Delete3; *\/ */ /* /\* stack_push(context->code_stack, &context->next); *\/ */ /* /\* if (current == current->parent->left) { *\/ */ /* /\* tmp->right->color = Black; *\/ */ /* /\* tree->current = current->parent; *\/ */ /* /\* goto meta(context, RotateL); *\/ */ /* /\* } else { *\/ */ /* /\* tmp->left->color = Black; *\/ */ /* /\* tree->current = current->parent; *\/ */ /* /\* goto meta(context, RotateR); *\/ */ /* /\* } *\/ */ /* /\* } *\/ */ /* /\* __code deleteCase6_stub(struct Context* context) { *\/ */ /* /\* goto deleteCase6(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */ /* /\* } *\/ */