# HG changeset patch # User Yasutaka Higa # Date 1458010357 -32400 # Node ID 24ae2641fec53500c56f8d8e4e3c9fc9b321ca78 # Parent 3f00d95339a7a352d82fa050ce6d8d347ef08c1f Show tree in llrb diff -r 3f00d95339a7 -r 24ae2641fec5 src/insert_verification/akashaLLRBContext.c --- a/src/insert_verification/akashaLLRBContext.c Tue Mar 15 11:45:17 2016 +0900 +++ b/src/insert_verification/akashaLLRBContext.c Tue Mar 15 11:52:37 2016 +0900 @@ -3,6 +3,7 @@ #include "akashaLLRBContext.h" extern __code insertOnce_stub(struct Context*); +extern __code showTree_stub(struct Context*); /* definitions from llrb */ extern __code meta(struct Context*); @@ -49,6 +50,7 @@ context->codeNum = Exit; context->code[InsertOnce] = insertOnce_stub; + context->code[ShowTree] = showTree_stub; /* definitions from llrb */ context->code[Put] = put_stub; diff -r 3f00d95339a7 -r 24ae2641fec5 src/insert_verification/include/akashaLLRBContext.h --- a/src/insert_verification/include/akashaLLRBContext.h Tue Mar 15 11:45:17 2016 +0900 +++ b/src/insert_verification/include/akashaLLRBContext.h Tue Mar 15 11:52:37 2016 +0900 @@ -5,6 +5,7 @@ enum Code { InsertOnce, + ShowTree, /* definitions from llrb */ Allocator, diff -r 3f00d95339a7 -r 24ae2641fec5 src/insert_verification/main.c --- a/src/insert_verification/main.c Tue Mar 15 11:45:17 2016 +0900 +++ b/src/insert_verification/main.c Tue Mar 15 11:52:37 2016 +0900 @@ -1,7 +1,18 @@ #include -#include "llrbContext.h" -#include "origin_cs.h" +#include "akashaLLRBContext.h" +#include "akashaCS.h" + + +void printTree(struct Node* node, int n) { + if (node != 0) { + printTree(node->left, n+1); + for (int i=0;ikey, node->value,/* n, */node->color==0? "R":"B", node); + printTree(node->right, n+1); + } +} __code insertOnce_stub(struct Context* context) { goto insertOnce(context, &context->data[Node]->node); @@ -9,15 +20,24 @@ __code insertOnce(struct Context* context, struct Node* node) { - // print_tree(context->data[Tree]->tree.root, 0); - // puts(""); - context->next = Exit; node->key = rand()%100+1; node->value = 100; + context->next = ShowTree; goto meta(context, Put); } +__code showTree_stub(struct Context* context) { + goto showTree(context, &context->data[Tree]->tree); +} + +__code showTree(struct Context* context, struct Tree* tree) { + printTree(tree->root, 0); + puts(""); + + goto meta(context, Exit); +} + int main(int argc, char const* argv[]) { goto startCode(InsertOnce); }