diff src/llrb/llrbContext.c @ 81:dc6f665bb753

implement delete(tail call). do not work
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Fri, 11 Dec 2015 15:06:20 +0900
parents 618c03f25108
children c13575c3dbe9
line wrap: on
line diff
--- a/src/llrb/llrbContext.c	Mon Nov 30 21:40:50 2015 +0900
+++ b/src/llrb/llrbContext.c	Fri Dec 11 15:06:20 2015 +0900
@@ -19,28 +19,30 @@
 extern __code colorFlip_stub(struct Context*);
 extern __code fixUp_stub(struct Context*);
 extern __code changeReference_stub(struct Context*);
-extern __code balance1_stub(struct Context*);
-extern __code balance2_stub(struct Context*);
-extern __code balance3_stub(struct Context*);
-extern __code balance4_stub(struct Context*);
-extern __code balance4_1_stub(struct Context*);
-extern __code balance4_2_stub(struct Context*);
-extern __code balance5_stub(struct Context*);
-extern __code setRoot_stub(struct Context*);
+extern __code insert1_stub(struct Context*);
+extern __code insert2_stub(struct Context*);
+extern __code insert3_stub(struct Context*);
+extern __code insert4_stub(struct Context*);
+extern __code insert4_1_stub(struct Context*);
+extern __code insert4_2_stub(struct Context*);
+extern __code insert5_stub(struct Context*);
+extern __code insert5_1_stub(struct Context*);
 extern __code get_stub(struct Context*);
-extern __code findMin_stub(struct Context*);
+extern __code search_stub(struct Context*);
 extern __code delete_stub(struct Context*);
-extern __code replaceNode_d1_stub(struct Context*);
-extern __code replaceNode_d2_stub(struct Context*);
-extern __code replaceNode_d3_stub(struct Context*);
-extern __code replaceNode_d4_stub(struct Context*);
-extern __code moveRedLeft1_stub(struct Context*);
-extern __code moveRedLeft2_stub(struct Context*);
-extern __code moveRedLeft3_stub(struct Context*);
-extern __code moveRedRight1_stub(struct Context*);
-extern __code moveRedRight2_stub(struct Context*);
-extern __code deleteMin1_stub(struct Context*);
-extern __code deleteMin2_stub(struct Context*);
+extern __code delete1_stub(struct Context*);
+extern __code delete2_stub(struct Context*);
+extern __code delete3_stub(struct Context*);
+extern __code replaceNodeForDelete1_stub(struct Context*);
+extern __code replaceNodeForDelete2_stub(struct Context*);
+extern __code findMax1_stub(struct Context*);
+extern __code findMax2_stub(struct Context*);
+extern __code deleteCase1_stub(struct Context*);
+extern __code deleteCase2_stub(struct Context*);
+extern __code deleteCase3_stub(struct Context*);
+extern __code deleteCase4_stub(struct Context*);
+extern __code deleteCase5_stub(struct Context*);
+extern __code deleteCase6_stub(struct Context*);
 extern __code exit_code(struct Context*);
 
 __code initLLRBContext(struct Context* context, int num) {
@@ -64,31 +66,30 @@
     context->code[Insert]     = insertNode_stub;
     context->code[RotateL]    = rotateLeft_stub;
     context->code[RotateR]    = rotateRight_stub;
-    context->code[ColorFlip]  = colorFlip_stub;
-    context->code[FixUp]      = fixUp_stub;
-    context->code[ChangeRef]  = changeReference_stub;
-    context->code[Balance1]   = balance1_stub;
-    context->code[Balance2]   = balance2_stub;
-    context->code[Balance3]   = balance3_stub;
-    context->code[Balance4]   = balance4_stub;
-    context->code[Balance4_1] = balance4_1_stub;
-    context->code[Balance4_2] = balance4_2_stub;
-    context->code[Balance5]   = balance5_stub;
-    context->code[SetRoot]    = setRoot_stub;
+    context->code[InsertCase1]   = insert1_stub;
+    context->code[InsertCase2]   = insert2_stub;
+    context->code[InsertCase3]   = insert3_stub;
+    context->code[InsertCase4]   = insert4_stub;
+    context->code[InsertCase4_1] = insert4_1_stub;
+    context->code[InsertCase4_2] = insert4_2_stub;
+    context->code[InsertCase5]   = insert5_stub;
+    context->code[InsertCase5_1] = insert5_1_stub;
     context->code[Get]        = get_stub;
-    context->code[Delete]     = delete_stub;
-    context->code[FindMin]    = findMin_stub;
-    context->code[Replace_d1] = replaceNode_d1_stub;
-    context->code[Replace_d2] = replaceNode_d2_stub;
-    context->code[Replace_d3] = replaceNode_d3_stub;
-    context->code[Replace_d4] = replaceNode_d4_stub;
-    context->code[MoveRedL1]  = moveRedLeft1_stub;
-    context->code[MoveRedL2]  = moveRedLeft2_stub;
-    context->code[MoveRedL3]  = moveRedLeft3_stub;
-    context->code[MoveRedR1]  = moveRedRight1_stub;
-    context->code[MoveRedR2]  = moveRedRight2_stub;
-    context->code[DeleteMin1] = deleteMin1_stub;
-    context->code[DeleteMin2] = deleteMin2_stub;
+    context->code[Search]        = search_stub;
+    context->code[Delete]        = delete_stub;
+    context->code[Delete1]       = delete1_stub;
+    context->code[Delete2]       = delete2_stub;
+    context->code[Delete3]       = delete3_stub;
+    context->code[Replace_d1] = replaceNodeForDelete1_stub;
+    context->code[Replace_d2] = replaceNodeForDelete2_stub;
+    context->code[FindMax1]    = findMax1_stub;
+    context->code[FindMax2]    = findMax2_stub;
+    context->code[DeleteCase1]   = deleteCase1_stub;
+    context->code[DeleteCase2]   = deleteCase2_stub;
+    context->code[DeleteCase3]   = deleteCase3_stub;
+    context->code[DeleteCase4]   = deleteCase4_stub;
+    context->code[DeleteCase5]   = deleteCase5_stub;
+    context->code[DeleteCase6]   = deleteCase6_stub;
     context->code[Exit]       = exit_code;
     
     context->heap = context->heapStart;
@@ -107,7 +108,7 @@
     struct Tree* tree = &context->data[Tree]->tree;
     tree->root = 0;
     tree->current = 0;
-    tree->prev = 0;
+    tree->deleted = 0;
     
     context->node_stack = stack_init(sizeof(union Data*), num);
     context->code_stack = stack_init(sizeof(enum Code), 100);