Mercurial > hg > Gears > Gears
changeset 1059:bc8f12df3f80
...
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 27 Jan 2024 17:58:43 +0900 |
parents | 37667b9d02f1 |
children | 5d8dce4e13df |
files | src/parallel_execution/RedBlackTree.cbc |
diffstat | 1 files changed, 29 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/RedBlackTree.cbc Fri Jan 26 17:41:14 2024 +0900 +++ b/src/parallel_execution/RedBlackTree.cbc Sat Jan 27 17:58:43 2024 +0900 @@ -260,6 +260,10 @@ tree->current = data; + if (tree->current == NULL) { + goto swap(tree); + } + goto inputStack->pop(up2); } @@ -269,24 +273,39 @@ struct Stack* inputStack = tree->inputStack; if (tree->current->right) { - goto up0(tree); - } else { - goto inputStack->pop(up); + // inputStackのtopにrightがあればup(すでにコピー済みなので) + // それがNULLならup3(rightDown)(そこからupしてきたのでNULLであるということはまだコピーできていないということになる(leftからのupをしたということ)) + goto up4(tree); } + + goto inputStack->pop(up); +} + +__code up4(struct RedBlackTree* tree) { + printf("up4\n"); + struct Stack* inputStack = tree->inputStack; + + goto inputStack->get(up0); } -__code up0(struct RedBlackTree* tree) { +__code up0(struct RedBlackTree* tree, struct Stack* stack) { printf("up0\n"); - struct Stack* nodeStack = tree->nodeStack; + struct Node* toTree = (Node*)(stack->data); - goto nodeStack->isEmpty(rightDown, swap); + if (toTree->right) { + goto up(tree); + } else { + goto up3(tree); + } + } -__code up3(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack) { +__code up3(struct RedBlackTree* tree) { printf("up3\n"); - tree->current->right = node->right; - - goto up(tree, inputStack); + struct Stack* nodeStack = tree->nodeStack; + + // nodeStack->isEmptyはupの最初にやるべき処理 + goto nodeStack->isEmpty(rightDown, swap); } __code swap(struct RedBlackTree* tree) {