1 #ifndef UNFOLDINGSTATETABLE_HH_ 2 #define UNFOLDINGSTATETABLE_HH_ 34 StateNode():_state(),_inf(),_tag(false),_children(){}
43 StateNode(
int i):_state(i),_inf(),_tag(false),_children(){
53 StateNode(
int i,
const T & inf):_state(i),_inf(inf),_tag(true),_children(){}
63 int state()
const {
return _state; }
85 list<StateNode *> *
children() {
return &_children; }
90 const list<StateNode *> *
children()
const {
return &_children; }
98 inline ostream& operator<<(ostream &os, const StateNode<T> & stateNode)
100 os <<
"***************************************************" << endl;
101 os <<
"Start StateNode: " << &stateNode << endl;
102 os <<
"***************************************************" << endl;
103 os <<
"\t state: " << stateNode.state() << endl;
104 os <<
"\t children: " << endl;
106 it != stateNode.children()->end();
111 os <<
"***************************************************" << endl;
112 os <<
"End StateNode: " << &stateNode << endl;
113 os <<
"***************************************************" << endl;
164 void printTable()
const;
179 void insertCube(
int * cube,
int index,
int size,
193 int * cube = s.
cube();
197 const list<StateNode<T> *> * currentListNode = &roots;
198 typename list<StateNode<T> *>::const_iterator currentNodeIt = currentListNode->begin();
202 if(currentNodeIt == currentListNode->end())
209 if( cube[index] < currentNode->
state() )
215 if(cube[index] == currentNode->
state())
217 if(index + 1 != size)
219 currentListNode = currentNode->
children();
220 currentNodeIt = currentListNode->begin();
248 int * cube = s.
cube();
253 list<StateNode<T> *> * currentListNode = &roots;
254 typename list<StateNode<T> *>::iterator currentNodeIt = currentListNode->begin();
258 if(currentNodeIt == currentListNode->end())
261 int previousSize = currentListNode->size();
263 insertCube(cube,index,size,*currentListNode,currentNodeIt,info);
265 "UnfoldingStateTable<T>::insertState is buggy");
272 if( cube[index] < currentNode->
state() )
274 insertCube(cube,index,size,*currentListNode,currentNodeIt,info);
280 if(cube[index] == currentNode->
state())
282 if(index + 1 != size)
284 currentListNode = currentNode->
children();
285 currentNodeIt = currentListNode->begin();
320 list<StateNode<T> *> * currentListNodePtr = ¤tListNode;
321 typename list<StateNode<T> *>::iterator currentNodeIt = nodeIt;
326 if(index2 + 1 == size)
336 int previousSize = currentListNodePtr-> size();
338 currentListNodePtr->insert(currentNodeIt,node);
342 "UnfoldingStateTable::insertState: the insertion has failed");
343 currentListNodePtr = node->
children();
345 "insertBs: problem of memory managment");
346 currentNodeIt = currentListNodePtr->end();
357 cout <<
"Empty table" << endl;
360 for(
typename list<
StateNode<T> * >::const_iterator rootsIt = roots.begin();
361 rootsIt != roots.end();
364 list< pair< const StateNode<T> *,
typename list<StateNode<T> *>::const_iterator> > stack;
365 stack.push_back(make_pair(*rootsIt, (*rootsIt)->children()->begin()));
366 while(!stack.empty())
369 typename list<StateNode<T> *>::const_iterator currentChild = stack.back().second;
370 if(currentChild != currentNode->
children()->end())
372 stack.back().second++;
373 stack.push_back(make_pair(*currentChild,(*currentChild)->children()->begin()));
381 stackIt= stack.begin();
382 stackIt != stack.end();
385 cout << stackIt->first->state() <<
" ";
393 cout <<
"There is a full sequence in the table that does not represent a Unfolding state: " << endl;
395 typename list<
StateNode<T> *>::const_iterator> >::const_iterator stackIt= stack.begin();
396 stackIt != stack.end();
399 cout << stackIt->first->state() <<
" ";
UnfoldingStateTable()
roots of the tree
const list< StateNode * > * children() const
T _inf
state of the StateNode
list< StateNode * > _children
is the information there or not ?
bool _tag
informtaion of the StateNode
#define require(Exception, expr, message)
Namespace of the Diades project.
StateNode()
list of node children
list< StateNode * > * children()
list< StateNode< T > * > roots
void setInfo(const T &inf)
#define assertion(Exception, expr, message)
StateNode(int i, const T &inf)