1 #include "DF_ChildIterator.hxx"
7 DF_ChildIterator::DF_ChildIterator(const DF_Label& theLabel, bool allLevels)
8 :_root(NULL), _current(NULL)
10 Init(theLabel, allLevels);
13 DF_ChildIterator::DF_ChildIterator()
14 :_root(NULL), _current(NULL)
18 DF_ChildIterator::~DF_ChildIterator()
24 //Initializes the iterator
25 void DF_ChildIterator::Init(const DF_Label& theLabel, bool allLevels)
27 _root = theLabel._node;
28 _allLevels = allLevels;
29 if(_root) _current = _root->_firstChild;
32 //Returns a current Label
33 DF_Label DF_ChildIterator::Value()
35 return DF_Label(_current);
38 //Returns true if there is a current Label
39 bool DF_ChildIterator::More()
41 return bool(_current);
44 //Moves to the next Label
45 void DF_ChildIterator::Next()
48 _current = _current->_next; //Move to the next brother
52 if(_current->_firstChild) { //Go down to the first child
53 _current = _current->_firstChild;
56 if(_current->_next) { //Next Brother
57 _current = _current->_next;
60 if(_current->_father && _current->_father != _root) {
61 DF_LabelNode *father = _current->_father;
62 _current = father->_next;
64 while(father && father != _root) {
65 father = father->_father;
66 if(father->_next) break;
68 if(father == _root) father = NULL;
69 if(father) _current = father->_next;
74 _current = NULL; //We iterate the whole sub tree