changeset 471:e5f0cced7d43

remove error ' rbtree'.
author ryokka
date Wed, 27 Dec 2017 21:17:02 +0900
parents 355f7f78e3cf
children fae47dc256b6
files src/parallel_execution/RedBlackTree.cbc
diffstat 1 files changed, 42 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/RedBlackTree.cbc	Wed Dec 27 20:21:30 2017 +0900
+++ b/src/parallel_execution/RedBlackTree.cbc	Wed Dec 27 21:17:02 2017 +0900
@@ -432,6 +432,7 @@
 
 __code deleteCase2(struct RedBlackTree* tree, struct Node* current, struct RotateTree* rotateTree) {
     struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
+    struct Stack* nodeStack = tree->nodeStack;
     
     if ((sibling == NULL ? Black : sibling->color) == Red) {
         tree->parent->color = Red;
@@ -446,13 +447,14 @@
         rotateTree->traverse = tree;
         rotateTree->next = C_deleteCase3;
 
-        if (current == tree->parent->left)
-            goto nodeStack->push(node,rotateLeft);
-        else
-            goto nodeStack->push(node,rotateRight);
+        if (current == tree->parent->left) {
+            goto nodeStack->push((union Data*)node,rotateLeft);
+        } else {
+            goto nodeStack->push((union Data*)node,rotateRight);
+        }
+
+        goto deleteCase3(tree,current);
     }
-
-    goto deleteCase3(tree,current);
 }
 
 
@@ -495,7 +497,8 @@
 
 __code deleteCase5(struct RedBlackTree* tree, struct Node* current, struct RotateTree* rotateTree) {
     struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
-    sibling->parent = tree->parent;
+    struct Stack* nodeStack = tree->nodeStack;
+    // sibling->parent = tree->parent;
     
     if (current == tree->parent->left &&
         (sibling == NULL ? Black : sibling->color) == Black &&
@@ -504,23 +507,28 @@
         sibling->color = Red;
         sibling->left->color = Black;
         
-        sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap);
-        allocator(context);
-        struct Node* tmp = &context->data[context->dataNum]->node;
+        // sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap);
+        sibling == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
+
+        struct Node* node = new Node();
+        node = sibling->left;
+
+        struct Node* tmp = node;
         *tmp = *sibling;
-        tmp->parent = current;
+        tree->parent = current;
         
         tmp->left = context->heap;
-        struct Node* node = new Node();
-        node = *sibling->left;
-        node->parent = tmp;
+/*         struct Node* node = new Node(); */
+/*         node = *sibling->left; */
+        tree->parent = tmp;
 
         tree->current = tmp;
         
+
         rotateTree->traverse = tree;
         rotateTree->next = C_deleteCase6;
 
-        goto nodeStack->push(node,rotateRight);
+        goto nodeStack->push((union Data*)node,rotateRight);
     } else if (current == tree->parent->right &&
                (sibling == NULL ? Black : sibling->color) == Black &&
                (sibling->left == NULL ? Black : sibling->left->color) == Black &&
@@ -528,23 +536,27 @@
         sibling->color = Red;
         sibling->right->color = Black;
 
-        sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap);
-        allocator(context);
-        struct Node* tmp = &context->data[context->dataNum]->node;
+        sibling == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
+
+        struct Node* node = new Node();
+        node = sibling->right;
+
+        struct Node* tmp = node;
         *tmp = *sibling;
-        tmp->parent = current;
+        // tmp->parent = current;
 
         tmp->right = context->heap;
-        struct Node* node = new Node();
-        node = *sibling->right;
-        node->parent = tmp;
+/*         struct Node* node = new Node(); */
+/*         node = *sibling->right; */
+        //node->parent = tmp;
 
         tree->current = tmp;
         
+
         rotateTree->traverse = tree;
         rotateTree->next = C_deleteCase6;
 
-        goto nodeStack->push(node,rotateLeft);
+        goto nodeStack->push((union Data*)node,rotateLeft);
     }
 
     goto deleteCase6(tree,current);
@@ -553,12 +565,12 @@
 
 __code deleteCase6(struct RedBlackTree* tree, struct Node* current, struct RotateTree* rotateTree) {
     struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
+    struct Stack* nodeStack = tree->nodeStack;
+    sibling == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
 
-    sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap);
-    allocator(context);
-    struct Node* tmp = &context->data[context->dataNum]->node;
-    *tmp = *sibling;
-    tmp->parent = current;
+    struct Node* tmp = sibling;
+    // *tmp = *sibling;
+    tree->parent = current;
 
     tmp->color = tree->parent->color;
     tree->parent->color = Black;
@@ -571,7 +583,7 @@
         rotateTree->traverse = tree;
         rotateTree->next = C_delete3;
 
-        goto nodeStack->push(node,rotateLeft);
+        goto nodeStack->push((union Data*)tmp,rotateLeft);
     } else {
         tmp->left->color = Black;
         tree->current = tree->parent;
@@ -579,6 +591,6 @@
         rotateTree->traverse = tree;
         rotateTree->next = C_delete3;
 
-        goto nodeStack->push(node,rotateLeft);
+        goto nodeStack->push((union Data*)tmp,rotateLeft);
     }
 }