# HG changeset patch # User Yasutaka Higa # Date 1458484771 -32400 # Node ID 3acaadc0a60cf0f7c7d36fe62acea4bacc52eed3 # Parent d6d6e075b49802c4af3d519d4ec797c88aa0ff22 Enumerate all insetion patterns diff -r d6d6e075b498 -r 3acaadc0a60c src/insert_verification/akashaLLRBContext.c --- a/src/insert_verification/akashaLLRBContext.c Sun Mar 20 22:47:53 2016 +0900 +++ b/src/insert_verification/akashaLLRBContext.c Sun Mar 20 23:39:31 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 duplicateIteratorElem_stub(struct Context*); extern __code goToPreviousDepth(struct Context*); /* definitions from llrb */ @@ -60,11 +61,12 @@ context->codeNum = Exit; - context->code[ShowTree] = showTree_stub; - context->code[IterateInsertion] = iterateInsertion_stub; - context->code[PutAndGoToNextDepth] = putAndGoToNextDepth_stub; - context->code[DuplicateIterator] = duplicateIterator_stub; - context->code[GoToPreviousDepth] = goToPreviousDepth; + context->code[ShowTree] = showTree_stub; + context->code[IterateInsertion] = iterateInsertion_stub; + context->code[PutAndGoToNextDepth] = putAndGoToNextDepth_stub; + context->code[DuplicateIterator] = duplicateIterator_stub; + context->code[DuplicateIteratorElem] = duplicateIterator_stub; + context->code[GoToPreviousDepth] = goToPreviousDepth; /* definitions from llrb */ context->code[Put] = put_stub; diff -r d6d6e075b498 -r 3acaadc0a60c src/insert_verification/include/akashaLLRBContext.h --- a/src/insert_verification/include/akashaLLRBContext.h Sun Mar 20 22:47:53 2016 +0900 +++ b/src/insert_verification/include/akashaLLRBContext.h Sun Mar 20 23:39:31 2016 +0900 @@ -1,14 +1,15 @@ /* Context definition for llrb example */ #include "stack.h" -#define ALLOCATE_SIZE 1000 -#define LIMIT_OF_VERIFICATION_SIZE 2 +#define ALLOCATE_SIZE 10000000 +#define LIMIT_OF_VERIFICATION_SIZE 4 enum Code { ShowTree, IterateInsertion, PutAndGoToNextDepth, DuplicateIterator, + DuplicateIteratorElem, GoToPreviousDepth, /* definitions from llrb */ diff -r d6d6e075b498 -r 3acaadc0a60c src/insert_verification/main.c --- a/src/insert_verification/main.c Sun Mar 20 22:47:53 2016 +0900 +++ b/src/insert_verification/main.c Sun Mar 20 23:39:31 2016 +0900 @@ -96,28 +96,28 @@ __code duplicateIteratorElem(struct Context* context, struct Allocate* allocate, struct Iterator* iter) { // All elements in iterator must be unique. - struct IterElem *oldElem = iter->previousDepth->head; + struct IterElem *oldElem = iter->previousDepth->head->next; struct IterElem *newElem = iter->head; - while (newElem->next != NULL) { // FIXME: simple implementation O(n^2) oldElem = oldElem->next; newElem = newElem->next; } - if (oldElem == iter->previousDepth->head) { + if (oldElem->val == iter->previousDepth->iteratedValue) { newElem->next = iter->head; - iter->last = newElem; + iter->last = iter->head; goto duplicateTree_stub(context); // meta } else { struct IterElem* dup = context->heap; allocate->size = sizeof(struct IterElem); allocator(context); - dup->val = oldElem->next->val; + dup->val = oldElem->val; newElem->next = dup; - goto duplicateIteratorElem_stub(context); // meta + goto duplicateIteratorElem_stub(context); + //goto meta(context, DuplicateIterElem); // meta } } @@ -137,7 +137,7 @@ showTrace(finishedIter); // FIXME: show trace - while (finishedIter->head == finishedIter->last) { + while (finishedIter->last == finishedIter->head) { if (finishedIter->previousDepth == NULL) { goto meta(context, ShowTree); // all enumerations finished. }