From 8f62b2de730241f2be82e55658bdb9ec6df8937d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 2 Apr 2013 01:38:51 +0200 Subject: [PATCH] WIP experiments cont finding out how adding dependant jobs could be done --- .../hierarchy-orientation-indicator-test.cpp | 82 ++++++++++++------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/tests/library/hierarchy-orientation-indicator-test.cpp b/tests/library/hierarchy-orientation-indicator-test.cpp index dfe1f692f..4703ece25 100644 --- a/tests/library/hierarchy-orientation-indicator-test.cpp +++ b/tests/library/hierarchy-orientation-indicator-test.cpp @@ -32,7 +32,7 @@ //#include #include -//#include +#include //////////////////////////////TODO #include #include #include @@ -42,8 +42,8 @@ using util::contains; using std::string; using util::isnil; -//using std::cout; -//using std::endl; +using std::cout; +using std::endl; namespace lib { namespace test { @@ -63,8 +63,10 @@ namespace test { const uint MAX_ID(100); const uint MAX_CHILDREN(5); const double CHILD_PROBABILITY(0.02); + const uint CHILDREN_TOTAL_LIMIT(20); const uint CHILDREN_SEED(20); + uint random_children_created(0); /** @@ -80,7 +82,10 @@ namespace test { ASSERT (0 < bottom); ASSERT (bottom < limit); + ++random_children_created; int cnt = (rand() % limit) - bottom; + if (random_children_created > CHILDREN_TOTAL_LIMIT) cnt=0; + if (0 < MAX (0, cnt)) cout << "Kau: "<< cnt < 0) { treeVisitation->orientation -= 1; - startChildTransaction(); + Node& refPoint = startChildTransaction(); populateBy (treeVisitation); - commitChildTransaction(); + commitChildTransaction(refPoint); } else { addNode (treeVisitation->id); ++treeVisitation; - } - } - } - - void - startChildTransaction() - { - - } - - void - commitChildTransaction() - { - - } + }}} + + private: + Node* parent; + Node* current; void addNode (int id) { - + current = & parent->makeChild(id); + } + + Node& + startChildTransaction() + { + Node& oldRefPoint (*parent); + ASSERT (current); + parent = current; // set new ref point + return oldRefPoint; + } + + void + commitChildTransaction(Node& refPoint) + { + parent = &refPoint; + current = parent; } }; - Builder builder; + + Builder builder(this->tree); builder.populateBy (treeVisitation); } - - void - attachNodeClone (VisitationData const& originalStructureInformation) - { - } - }; @@ -343,6 +364,7 @@ namespace test { void demonstrate_tree_rebuilding ( ) { Node testTree (-1, CHILDREN_SEED); + cout << "testing with a tree of size="<