changeset 1042:751d26c368fb

fix asterisk position in Tree.h
author matac42 <matac@cr.ie.u-ryukyu.ac.jp>
date Mon, 13 Nov 2023 19:59:35 +0900
parents 9b2f5dc02b2a
children 1098071e12b8
files src/parallel_execution/Gears_CbC.md src/parallel_execution/RedBlackTree.cbc src/parallel_execution/Tree.h
diffstat 3 files changed, 42 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/Gears_CbC.md	Mon Nov 13 19:59:35 2023 +0900
@@ -0,0 +1,28 @@
+## ヘッダーファイルを作成するときはアスタリスクの位置に注意する
+
+### O
+
+Impl* tree
+
+### X
+
+Impl *tree
+
+### 正しい例
+
+```
+typedef struct Tree<> {
+  /* future Code */
+  /* Type* tree; */
+  /* Type* node; */
+  union Data* tree;
+  struct Node* node;
+  __code put(Impl* tree, Type* node, __code next(...));
+  __code get(Impl* tree, Type* node, __code next(...));
+  __code remove(Impl* tree, Type* node, __code next(...));
+  __code copy(Impl* tree, Type* node, __code next(...));
+  // __code clearRedBlackTree();
+  __code next(...);
+} Tree;
+```
+
--- a/src/parallel_execution/RedBlackTree.cbc	Sun Nov 12 12:19:56 2023 +0900
+++ b/src/parallel_execution/RedBlackTree.cbc	Mon Nov 13 19:59:35 2023 +0900
@@ -110,10 +110,10 @@
 
 __code leftDown1(struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack) {
     struct Stack* nodeStack = tree->nodeStack;
-    if (tree->left) {
-        goto leftDown(tree->left, inputStack, outputStack);
-    } else if (tree->right) {
-        goto rightDown(tree->right, inputStack, outputStack);
+    if (tree->current->left) {
+        goto leftDown(tree->current->left, inputStack, outputStack);
+    } else if (tree->current->right) {
+        goto rightDown(tree->current->right, inputStack, outputStack);
     } else {
         goto nodeStack->pop(up);
     }
@@ -136,7 +136,7 @@
     if (node->left) {
         tree->current = node->right;
         node->left = newNode;
-        goto push((union Data*)node, rightDown);
+        goto nodeStack->push((union Data*)node, rightDown);
     } else {
         node->right = newNode;
         newNode = node;
@@ -144,18 +144,15 @@
     }
 }
 
-__code popWhenEmpty(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack) {
-    struct Stack* nodeStack = tree->nodeStack;
+__code popWhenEmpty(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack, __code next(...)) {
     goto next(...);
 }
 
-__code popWhenNoEmpty(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack) {
-    struct Stack* nodeStack = tree->nodeStack;
+__code popWhenNoEmpty(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack, struct Stack* nodeStack) {
     goto nodeStack->pop(up1);
 }
 
-__code up1(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack) {
-    struct Stack* nodeStack = tree->nodeStack;
+__code up1(struct Node* node, struct RedBlackTree* tree, struct Stack* inputStack, struct Stack* outputStack, struct Stack* nodeStack) {
     goto nodeStack->pop(up2);
 }
 
--- a/src/parallel_execution/Tree.h	Sun Nov 12 12:19:56 2023 +0900
+++ b/src/parallel_execution/Tree.h	Mon Nov 13 19:59:35 2023 +0900
@@ -2,12 +2,12 @@
   /* future Code */
   /* Type* tree; */
   /* Type* node; */
-  union Data *tree;
-  struct Node *node;
-  __code put(Impl *tree, Type *node, __code next(...));
-  __code get(Impl *tree, Type *node, __code next(...));
-  __code remove(Impl *tree, Type *node, __code next(...));
-  __code copy(Impl *tree, Type *node, __code next(...));
+  union Data* tree;
+  struct Node* node;
+  __code put(Impl* tree, Type* node, __code next(...));
+  __code get(Impl* tree, Type* node, __code next(...));
+  __code remove(Impl* tree, Type* node, __code next(...));
+  __code copy(Impl* tree, Type* node, __code next(...));
   // __code clearRedBlackTree();
   __code next(...);
 } Tree;