comparison src/parallel_execution/rb_tree.c @ 173:8260b230dc2f

fix RedBlackTree.c
author ikkun
date Thu, 24 Nov 2016 20:51:32 +0900
parents 661b0b0d0399
children f9ed0b8f7132
comparison
equal deleted inserted replaced
172:661b0b0d0399 173:8260b230dc2f
125 &context->data[D_Stack]->stack, 125 &context->data[D_Stack]->stack,
126 &context->data[D_Node]->node, 126 &context->data[D_Node]->node,
127 context->data[D_RedBlackTree]->RedBlackTree.newNode); 127 context->data[D_RedBlackTree]->RedBlackTree.newNode);
128 } 128 }
129 129
130 __code insertCase1(struct Context* context,struct RedBlackTree* traverse, struct RedBlackTree* tree,struct Node *parent, struct Node *grandparent) { 130 __code insertCase1(struct Context* context, struct RedBlackTree* traverse, struct Node *parent, struct Node *grandparent) {
131 if (parent != NULL) { 131 if (parent != NULL) {
132 traverse->parent = parent; 132 traverse->parent = parent;
133 traverse->grandparent = grandparent; 133 traverse->grandparent = grandparent;
134 goto meta(context,C_insertCase2); 134 goto meta(context,C_insertCase2);
135 } 135 }
136 tree->root->color = Black; 136 traverse->root->color = Black;
137 goto meta(context, C_stackClear); 137 goto meta(context, C_stackClear);
138 } 138 }
139 139
140 __code insertCase1_stub(struct Context* context) { 140 __code insertCase1_stub(struct Context* context) {
141 goto insertCase1(context, 141 goto insertCase1(context,
142 &context->data[D_RedBlackTree]->RedBlackTree, 142 &context->data[D_RedBlackTree]->RedBlackTree,
143 &context->data[D_Tree]->Tree,
144 &context->data[D_Stack]->stack.data->node, 143 &context->data[D_Stack]->stack.data->node,
145 &context->data[D_Stack]->stack.data1->node); 144 &context->data[D_Stack]->stack.data1->node);
146 } 145 }
147 146
148 __code insertCase2(struct Context* context, struct RedBlackTree* traverse) { 147 __code insertCase2(struct Context* context, struct RedBlackTree* traverse) {
282 __code rotateLeft1_stub(struct Context* context) { 281 __code rotateLeft1_stub(struct Context* context) {
283 struct RedBlackTree* traverse = context->data[D_RotateTree]->rotateTree.traverse; 282 struct RedBlackTree* traverse = context->data[D_RotateTree]->rotateTree.traverse;
284 struct Node* parent = &context->data[D_Stack]->stack.data->node; 283 struct Node* parent = &context->data[D_Stack]->stack.data->node;
285 goto rotateLeft1(context, 284 goto rotateLeft1(context,
286 traverse->current, 285 traverse->current,
287 &context->data[D_Tree]->Tree,
288 traverse, 286 traverse,
289 parent, 287 parent,
290 &context->data[D_RotateTree]->rotateTree); 288 &context->data[D_RotateTree]->rotateTree);
291 } 289 }
292 290
323 __code rotateRight1_stub(struct Context* context) { 321 __code rotateRight1_stub(struct Context* context) {
324 struct RedBlackTree* traverse = context->data[D_RotateTree]->rotateTree.traverse; 322 struct RedBlackTree* traverse = context->data[D_RotateTree]->rotateTree.traverse;
325 struct Node* parent = &context->data[D_Stack]->stack.data->node; 323 struct Node* parent = &context->data[D_Stack]->stack.data->node;
326 goto rotateRight1(context, 324 goto rotateRight1(context,
327 traverse->current, 325 traverse->current,
328 &context->data[D_Tree]->Tree,
329 traverse, 326 traverse,
330 parent, 327 parent,
331 &context->data[D_RotateTree]->rotateTree); 328 &context->data[D_RotateTree]->rotateTree);
332 } 329 }
333 330
342 goto stackClear(context, &context->data[D_RedBlackTree]->RedBlackTree,&context->data[D_Stack]->stack); 339 goto stackClear(context, &context->data[D_RedBlackTree]->RedBlackTree,&context->data[D_Stack]->stack);
343 } 340 }
344 341
345 342
346 __code getRedBlackTree(struct Context* context, struct RedBlackTree* traverse) { 343 __code getRedBlackTree(struct Context* context, struct RedBlackTree* traverse) {
347 if (tree->root) { 344 if (traverse->root) {
348 traverse->current = tree->root; 345 traverse->current = traverse->root;
349 346
350 goto meta(context, C_search); 347 goto meta(context, C_search);
351 } 348 }
352 349
353 goto meta(context, traverse->next); 350 goto meta(context, traverse->next);
354 } 351 }
355 352
356 __code getRedBlackTree_stub(struct Context* context) { 353 __code getRedBlackTree_stub(struct Context* context) {
357 goto get(context, &context->data[D_Tree]->tree, &context->data[D_RedBlackTree]->RedBlackTree); 354 goto getRedBlackTree(context, &context->data[D_RedBlackTree]->RedBlackTree);
358 } 355 }
359 356
360 __code search(struct Context* context, struct RedBlackTree* traverse, struct Node* node) { 357 __code search(struct Context* context, struct RedBlackTree* traverse, struct Node* node) {
361 // compare(context, traverse, traverse->current->key, node->key); 358 // compare(context, traverse, traverse->current->key, node->key);
362 traverse->result = compare(traverse->current, node); 359 traverse->result = compare(traverse->current, node);