latest version v1.9 - last update 10 Apr 2010 |
Iterator type (allows read and write operations). More...
#include <ltiTree.h>
Public Member Functions | |
iterator () | |
iterator (const iterator &other) | |
iterator & | operator++ () |
bool | operator== (const iterator &other) const |
bool | operator!= (const iterator &other) const |
node & | operator* () |
iterator & | operator= (const iterator &other) |
Protected Member Functions | |
iterator (node &theNode, nodeManager &owner) | |
Protected Attributes | |
std::list< int > | stack |
node * | pointedNode |
nodeManager * | theOwner |
Iterator type (allows read and write operations).
The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See lti::tree::begin() for an example
CAUTION: Try to use the prefix incremental operator (i.e. ++it) instead of the postfix operator (i.e. it++) to allow efficient code!
CAUTION: Do not delete sibling nodes of already iterated nodes: the iterator keeps track of them, and if you delete them invalid references to unexistent nodes could be returned by late iterations. It IS save to insert or delete children of the nodes pointed by the iterator (but this could invalidate other iterators on the same tree). If you really really need to do things like that, you should use your own node pointers and iteration mechanisms :-(
The iterators will traverse the tree in a prefix form (first the node and then the children)
lti::tree< T >::iterator::iterator | ( | node & | theNode, | |
nodeManager & | owner | |||
) | [inline, explicit, protected] |
lti::tree< T >::iterator::iterator | ( | ) | [inline] |
Default constructor.
Copy constructor.
bool lti::tree< T >::iterator::operator!= | ( | const iterator & | other | ) | const [inline] |
Compare this iterator with the other one.
References lti::tree< T >::iterator::pointedNode.
Get pointed data.
References lti::tree< T >::iterator::pointedNode.
Advance to next item (prefix increment operator).
References lti::tree< T >::node::child(), lti::tree< T >::node::degree(), lti::tree< T >::nodeManager::getIndexOfNode(), lti::tree< T >::nodeManager::getNode(), lti::tree< T >::node::isChildValid(), lti::tree< T >::iterator::pointedNode, lti::tree< T >::size(), lti::tree< T >::iterator::stack, and lti::tree< T >::iterator::theOwner.
Copy member.
References lti::tree< T >::iterator::pointedNode, lti::tree< T >::iterator::stack, and lti::tree< T >::iterator::theOwner.
bool lti::tree< T >::iterator::operator== | ( | const iterator & | other | ) | const [inline] |
Compare this iterator with the other one.
References lti::tree< T >::iterator::pointedNode.
node* lti::tree< T >::iterator::pointedNode [protected] |
The pointed node.
Referenced by lti::tree< T >::const_iterator::operator!=(), lti::tree< T >::iterator::operator!=(), lti::tree< T >::iterator::operator*(), lti::tree< T >::iterator::operator++(), lti::tree< T >::const_iterator::operator=(), lti::tree< T >::iterator::operator=(), lti::tree< T >::const_iterator::operator==(), and lti::tree< T >::iterator::operator==().
std::list<int> lti::tree< T >::iterator::stack [protected] |
Stack with all still-to-be-iterated-children.
Referenced by lti::tree< T >::iterator::operator++(), lti::tree< T >::const_iterator::operator=(), and lti::tree< T >::iterator::operator=().
nodeManager* lti::tree< T >::iterator::theOwner [protected] |
The owner tree.
Referenced by lti::tree< T >::iterator::operator++(), lti::tree< T >::const_iterator::operator=(), and lti::tree< T >::iterator::operator=().