changeset 16:3acaadc0a60c

Enumerate all insetion patterns
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Sun, 20 Mar 2016 23:39:31 +0900
parents d6d6e075b498
children 1034102aff1e
files src/insert_verification/akashaLLRBContext.c src/insert_verification/include/akashaLLRBContext.h src/insert_verification/main.c
diffstat 3 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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 */
--- 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.
         }