Mercurial > hg > Gears > Gears
changeset 1052:cbcdd05bd65c
rm leftDown0, up0
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 25 Jan 2024 18:12:41 +0900 |
parents | 62e938b798ec |
children | e53cbb2fa8b0 |
files | src/parallel_execution/RedBlackTree.cbc |
diffstat | 1 files changed, 33 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/RedBlackTree.cbc Thu Jan 25 17:24:51 2024 +0900 +++ b/src/parallel_execution/RedBlackTree.cbc Thu Jan 25 18:12:41 2024 +0900 @@ -107,10 +107,10 @@ printf("leftDown\n"); - goto inputStack->get(leftDown0); + goto inputStack->get(leftDown1); } -__code leftDown0(struct Node* node, struct RedBlackTree* tree, struct Stack* stack) { +__code leftDown1(struct Node* node, struct RedBlackTree* tree, struct Stack* stack) { struct Stack* inputStack = tree->inputStack; struct Node* newNode = &ALLOCATE(context, Node)->Node; struct Node* data = (Node*)(stack->data); @@ -123,25 +123,25 @@ data->left = newNode; } - printf("leftDown0\n"); + printf("leftDown1\n"); // 新規ノードをpushしている - goto inputStack->push(newNode, leftDown1); + goto inputStack->push(newNode, leftDown2); } // 実際にDownする -__code leftDown1(struct RedBlackTree* tree) { +__code leftDown2(struct RedBlackTree* tree) { struct Stack* nodeStack = tree->nodeStack; struct Node* oldNode = tree->current; tree->current = tree->current->left; - printf("leftDown1\n"); - goto nodeStack->push((union Data*)oldNode, leftDown2); + printf("leftDown2\n"); + goto nodeStack->push((union Data*)oldNode, leftDown3); } -__code leftDown2(struct RedBlackTree* tree) { +__code leftDown3(struct RedBlackTree* tree) { struct Stack* inputStack = tree->inputStack; - printf("leftDown2\n"); + printf("leftDown3\n"); if (tree->current) { goto leftDown(tree, inputStack); } else if (tree->current == NULL) { @@ -168,34 +168,47 @@ // // upしつつright見つつ // NULLからのup +// nodeStackが空だったらtreeの入れ替えへ +// __code up(struct RedBlackTree* tree) { struct Stack* nodeStack = tree->nodeStack; printf("up\n"); // current付け替えしたい // getして付け替えてpopだな... - goto nodeStack->get(up0); + goto nodeStack->get(up1); } -__code up0(struct RedBlackTree* tree, struct Stack* stack) { +__code up1(struct RedBlackTree* tree, struct Stack* stack) { struct Stack* nodeStack = tree->nodeStack; struct Node* data = (Node*)(stack->data); tree->current = data; - printf("up0\n"); + if (tree->current == NULL) { + // 木の入れ替え + // copyの終了 + printf("copy finished!\n"); + } - goto nodeStack->pop(up1); + printf("up1\n"); + + goto nodeStack->pop(up2); } // rightを見てさらにupするか考える -__code up1(struct RedBlackTree* tree) { - struct Stack* nodeStack = tree->nodeStack; - printf("up1\n"); - goto nodeStack->pop(up2); +__code up2(struct RedBlackTree* tree) { + struct Stack* inputStack = tree->inputStack; + printf("up2\n"); + if (tree->current->right) { + tree->current = tree->current->right; + goto rightDown(tree); + } + + goto inputStack->pop(up); } -__code up2(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack) { - printf("up2\n"); +__code up3(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack) { + printf("up3\n"); tree->current->right = node->right; goto up(tree, inputStack); } @@ -216,7 +229,7 @@ __code popWhenNoEmpty(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack) { struct Stack* nodeStack = tree->nodeStack; printf("popWhenNoEmpty\n"); - goto nodeStack->pop(up1); + goto nodeStack->pop(up2); } __code insertNode(struct RedBlackTree* tree, struct Node* node) {