Mercurial > hg > Gears > Gears
changeset 1053:e53cbb2fa8b0
...
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 25 Jan 2024 19:21:01 +0900 |
parents | cbcdd05bd65c |
children | 7274db9ef926 |
files | src/parallel_execution/RedBlackTree.cbc |
diffstat | 1 files changed, 49 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/RedBlackTree.cbc Thu Jan 25 18:12:41 2024 +0900 +++ b/src/parallel_execution/RedBlackTree.cbc Thu Jan 25 19:21:01 2024 +0900 @@ -110,7 +110,7 @@ goto inputStack->get(leftDown1); } -__code leftDown1(struct Node* node, struct RedBlackTree* tree, struct Stack* stack) { +__code leftDown1(struct RedBlackTree* tree, struct Stack* stack) { struct Stack* inputStack = tree->inputStack; struct Node* newNode = &ALLOCATE(context, Node)->Node; struct Node* data = (Node*)(stack->data); @@ -146,23 +146,64 @@ goto leftDown(tree, inputStack); } else if (tree->current == NULL) { goto inputStack->pop(up); - // このあとnodeStack->popが必要 } else if (tree->current->left) { + // 謎の処理 + printf("nazo\n"); goto rightDown(tree, inputStack); } } -__code rightDown(struct RedBlackTree* tree, struct Stack* inputStack) { +__code rightDown(struct RedBlackTree* tree) { + struct Stack* inputStack = tree->inputStack; + + printf("rightDown\n"); + + goto inputStack->get(rightDown1); +} + +// inputStackに2をpushしてなくない? +__code rightDown1(struct RedBlackTree* tree, struct Stack* stack) { + struct Stack* inputStack = tree->inputStack; struct Node* newNode = &ALLOCATE(context, Node)->Node; + struct Node* data = (Node*)(stack->data); newNode->key = tree->current->key; newNode->value = (union Data*)new Integer(); ((Integer*)newNode->value)->value = ((Integer*)tree->current->value)->value; newNode->color = tree->current->color; - newNode->right = tree->current->right; - tree->current = tree->current->right; + + if(data) { + data->right = newNode; + } + + printf("rightDown1\n"); + + // 新規ノードをpushしている + goto inputStack->push(newNode, rightDown2); +} + +// 実際にDownする +__code rightDown2(struct RedBlackTree* tree) { struct Stack* nodeStack = tree->nodeStack; - printf("rightDown\n"); - goto nodeStack->push(newNode, leftDown); + struct Node* oldNode = tree->current; + tree->current = tree->current->right; + + printf("rightDown2\n"); + goto nodeStack->push((union Data*)oldNode, rightDown3); +} + +__code rightDown3(struct RedBlackTree* tree) { + struct Stack* inputStack = tree->inputStack; + printf("rightDown3\n"); + if (tree->current) { + goto leftDown(tree, inputStack); + } else if (tree->current == NULL) { + // currentの付け替えは? + goto inputStack->pop2(rightDown); + } else if (tree->current->left) { + // 謎の処理 + printf("nazo\n"); + goto rightDown(tree, inputStack); + } } // @@ -192,6 +233,7 @@ printf("up1\n"); + // rightの状態を見る前にpopしてしまっている気がする goto nodeStack->pop(up2); }