# HG changeset patch # User Yasutaka Higa # Date 1458468343 -32400 # Node ID 1bbaafdafa477eeca17216a23f86fdd32abce4fa # Parent f0a1f02e8493e12a1444ecc750999afbff174cc0 Enumerates all paths diff -r f0a1f02e8493 -r 1bbaafdafa47 src/insert_verification/akashaLLRBContext.c --- a/src/insert_verification/akashaLLRBContext.c Sun Mar 20 18:23:58 2016 +0900 +++ b/src/insert_verification/akashaLLRBContext.c Sun Mar 20 19:05:43 2016 +0900 @@ -6,6 +6,7 @@ extern __code iterateInsertion_stub(struct Context*); extern __code putAndGoToNextDepth_stub (struct Context*); extern __code duplicateIterator_stub(struct Context*); +extern __code goToPreviousDepth(struct Context*); /* definitions from llrb */ extern __code meta(struct Context*, enum Code next); @@ -63,6 +64,7 @@ context->code[IterateInsertion] = iterateInsertion_stub; context->code[PutAndGoToNextDepth] = putAndGoToNextDepth_stub; context->code[DuplicateIterator] = duplicateIterator_stub; + context->code[GoToPreviousDepth] = goToPreviousDepth; /* definitions from llrb */ context->code[Put] = put_stub; diff -r f0a1f02e8493 -r 1bbaafdafa47 src/insert_verification/include/akashaLLRBContext.h --- a/src/insert_verification/include/akashaLLRBContext.h Sun Mar 20 18:23:58 2016 +0900 +++ b/src/insert_verification/include/akashaLLRBContext.h Sun Mar 20 19:05:43 2016 +0900 @@ -2,13 +2,14 @@ #include "stack.h" #define ALLOCATE_SIZE 1000 -#define LIMIT_OF_VERIFICATION_SIZE 2 +#define LIMIT_OF_VERIFICATION_SIZE 4 enum Code { ShowTree, IterateInsertion, PutAndGoToNextDepth, DuplicateIterator, + GoToPreviousDepth, /* definitions from llrb */ Allocator, diff -r f0a1f02e8493 -r 1bbaafdafa47 src/insert_verification/main.c --- a/src/insert_verification/main.c Sun Mar 20 18:23:58 2016 +0900 +++ b/src/insert_verification/main.c Sun Mar 20 19:05:43 2016 +0900 @@ -56,8 +56,10 @@ node->value = iter->head->val; iter->head = iter->head->next; + printf("%d\n", node->value); + if (iter->head == iter->last) { - context->next = ShowTree; // TODO: add restore and back trace + context->next = GoToPreviousDepth; } else { context->next = DuplicateIterator; } @@ -131,7 +133,21 @@ __code duplicateTree(struct Context* context, struct Tree* tree, struct Iterator* iter) { // Tree must be non destructive. // If you use destructive tree, you must copy tree. - iter->tree = tree; + iter->previousDepth->tree = tree; + goto meta(context, PutAndGoToNextDepth); +} + +__code goToPreviousDepth(struct Context* context) { + struct Iterator* finishedIter = &context->data[Iter]->iterator; + + if (finishedIter->previousDepth == NULL) { + goto meta(context, ShowTree); // all enumerations finished. + } + + context->data[Iter] = (union Data*)finishedIter->previousDepth; + context->data[Tree] = (union Data*)finishedIter->previousDepth->tree; + // TODO: cleanup memory + goto meta(context, PutAndGoToNextDepth); }