Mercurial > hg > Members > Moririn
comparison 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 |
comparison
equal
deleted
inserted
replaced
138:04a2f486a30d | 139:c13b07d15d86 |
---|---|
110 &context->data[Traverse]->traverse, | 110 &context->data[Traverse]->traverse, |
111 &context->data[Node]->node, | 111 &context->data[Node]->node, |
112 context->data[Traverse]->traverse.newNode); | 112 context->data[Traverse]->traverse.newNode); |
113 } | 113 } |
114 | 114 |
115 __code insertCase1(struct Context* context, struct Tree* tree, struct SingleLinkedStack* nodeStack) { | 115 __code insertCase1(struct Context* context,struct Traverse* traverse, struct Tree* tree, struct Stack* nodeStack) { |
116 if (nodeStack->top != NULL) { | 116 struct SingleLinkedStack* stack = (struct SingleLinkedStack*)traverse->nodeStack->stack; |
117 goto meta(context, InsertCase2); | 117 if (stack->top != NULL) { |
118 nodeStack->stack = (union Data*)traverse->nodeStack; | |
119 nodeStack->next = InsertCase2; | |
120 goto meta(context, traverse->nodeStack->get); | |
118 } | 121 } |
119 tree->root->color = Black; | 122 tree->root->color = Black; |
120 goto meta(context, StackClear); | 123 goto meta(context, StackClear); |
121 } | 124 } |
122 | 125 |
123 __code insert1_stub(struct Context* context) { | 126 __code insert1_stub(struct Context* context) { |
124 goto insertCase1(context, | 127 goto insertCase1(context, |
128 &context->data[Traverse]->traverse, | |
125 &context->data[Tree]->tree, | 129 &context->data[Tree]->tree, |
126 &context->data[Traverse]->traverse.nodeStack->stack->singleLinkedStack); | 130 &context->data[Stack]->stack); |
127 } | 131 } |
128 | 132 |
129 __code insertCase2(struct Context* context, struct Traverse* traverse, struct Stack* nodeStack, struct Node* parent) { | 133 __code insertCase2(struct Context* context, struct Traverse* traverse, struct Stack* nodeStack, struct Node* parent) { |
130 if (parent->color == Black) { | 134 if (parent->color == Black) { |
131 goto meta(context, StackClear); | 135 goto meta(context, StackClear); |
178 if ((current == parent->right) && (parent == grandparent->left)) { | 182 if ((current == parent->right) && (parent == grandparent->left)) { |
179 traverse->current = traverse->current->left; | 183 traverse->current = traverse->current->left; |
180 traverse->rotateNext = InsertCase5; | 184 traverse->rotateNext = InsertCase5; |
181 nodeStack->stack = (union Data*)traverse->nodeStack; | 185 nodeStack->stack = (union Data*)traverse->nodeStack; |
182 nodeStack->next = RotateL; | 186 nodeStack->next = RotateL; |
183 goto meta(context, nodeStack->get); | 187 goto meta(context, nodeStack->pop); |
184 } else if ((current == parent->left) && (parent == grandparent->right)) { | 188 } else if ((current == parent->left) && (parent == grandparent->right)) { |
185 traverse->current = traverse->current->right; | 189 traverse->current = traverse->current->right; |
186 traverse->rotateNext = InsertCase5; | 190 traverse->rotateNext = InsertCase5; |
187 nodeStack->stack = (union Data*)traverse->nodeStack; | 191 nodeStack->stack = (union Data*)traverse->nodeStack; |
188 nodeStack->next = RotateR; | 192 nodeStack->next = RotateR; |
189 goto meta(context, nodeStack->get); | 193 goto meta(context, nodeStack->pop); |
190 } | 194 } |
191 | 195 |
192 traverse->current = current; | 196 traverse->current = current; |
193 goto meta(context, InsertCase5); | 197 goto meta(context, InsertCase5); |
194 } | 198 } |
201 | 205 |
202 __code insertCase5(struct Context* context, struct Traverse* traverse) { | 206 __code insertCase5(struct Context* context, struct Traverse* traverse) { |
203 struct Stack* nodeStack = traverse->nodeStack; | 207 struct Stack* nodeStack = traverse->nodeStack; |
204 nodeStack->stack = (union Data*)traverse->nodeStack; | 208 nodeStack->stack = (union Data*)traverse->nodeStack; |
205 nodeStack->next = InsertCase51; | 209 nodeStack->next = InsertCase51; |
206 goto meta(context, nodeStack->pop2); | 210 goto meta(context, nodeStack->get2); |
207 } | 211 } |
208 | 212 |
209 __code insert5_stub(struct Context* context) { | 213 __code insert5_stub(struct Context* context) { |
210 goto insertCase5(context, &context->data[Traverse]->traverse); | 214 goto insertCase5(context, &context->data[Traverse]->traverse); |
211 } | 215 } |