latest version v1.9 - last update 10 Apr 2010 |
The nodeManager takes care of the memory administration. More...
#include <ltiTree.h>
Public Member Functions | |
nodeManager (const int &n) | |
node * | createNode (const int &n, node &theNewParent, const T &newData=T()) |
node * | createNode (const int &n, node *theNewParent, const T &newData=T()) |
node * | createNode (node &theNewParent, const T &newData=T()) |
void | freeNode (node &theNode) |
node * | getNode (const int &idx) |
const node * | getNode (const int &idx) const |
int | getIndexOfNode (const node &aNode) const |
const int & | size () const |
Protected Attributes | |
std::vector< node * > | theNodes |
std::list< int > | freedNodes |
int | theSize |
int | theDegree |
The nodeManager takes care of the memory administration.
It is required to ensure that the iterators do not access invalid memory
lti::tree< T >::nodeManager::nodeManager | ( | const int & | n | ) | [inline] |
Constructor.
n | the degree of each new node created |
node* lti::tree< T >::nodeManager::createNode | ( | node & | theNewParent, | |
const T & | newData = T() | |||
) | [inline] |
Creates a new node with the standard degree (specified in construction of the node manager) and returns the index of that node in theNodes.
References lti::tree< T >::nodeManager::createNode(), and lti::tree< T >::nodeManager::theDegree.
node* lti::tree< T >::nodeManager::createNode | ( | const int & | n, | |
node * | theNewParent, | |||
const T & | newData = T() | |||
) | [inline] |
Creates a new node and returns the index of that node in theNodes.
n | initial number of children (degree) for this node | |
theNewParent | pointer to the parent node of this node | |
newData | the data to be hold on this node |
References lti::tree< T >::nodeManager::freedNodes, lti::tree< T >::nodeManager::theNodes, and lti::tree< T >::nodeManager::theSize.
node* lti::tree< T >::nodeManager::createNode | ( | const int & | n, | |
node & | theNewParent, | |||
const T & | newData = T() | |||
) | [inline] |
Creates a new node and returns the index of that node in theNodes.
n | initial number of children (degree) for this node | |
theNewParent | the parent node of this node | |
newData | the data to be hold on this node |
References lti::tree< T >::nodeManager::freedNodes, lti::tree< T >::nodeManager::theNodes, and lti::tree< T >::nodeManager::theSize.
Referenced by lti::tree< T >::node::appendChild(), lti::tree< T >::node::copy(), lti::tree< T >::nodeManager::createNode(), and lti::tree< T >::node::insertChild().
Free the given node and all its sucessors.
References lti::tree< T >::node::child(), lti::tree< T >::node::degree(), lti::tree< T >::nodeManager::freedNodes, lti::tree< T >::node::index(), lti::tree< T >::node::isChildValid(), lti::tree< T >::nodeManager::theNodes, and lti::tree< T >::nodeManager::theSize.
Referenced by lti::tree< T >::node::deleteChild(), lti::tree< T >::node::moveChild(), and lti::tree< T >::node::setDegree().
int lti::tree< T >::nodeManager::getIndexOfNode | ( | const node & | aNode | ) | const [inline] |
Get index of the given node.
References lti::tree< T >::node::index().
Referenced by lti::tree< T >::const_iterator::operator++(), and lti::tree< T >::iterator::operator++().
const node* lti::tree< T >::nodeManager::getNode | ( | const int & | idx | ) | const [inline] |
Get pointer to the node at the given index.
References lti::tree< T >::nodeManager::theNodes.
Get pointer to the node at the given index.
References lti::tree< T >::nodeManager::theNodes.
Referenced by lti::tree< T >::const_iterator::operator++(), and lti::tree< T >::iterator::operator++().
const int& lti::tree< T >::nodeManager::size | ( | ) | const [inline] |
Returns the number of valid nodes until now.
References lti::tree< T >::nodeManager::theSize.
std::list<int> lti::tree< T >::nodeManager::freedNodes [protected] |
Freed nodes.
This list contains the indices of freed nodes, which can be used by the next createNode
Referenced by lti::tree< T >::nodeManager::createNode(), and lti::tree< T >::nodeManager::freeNode().
int lti::tree< T >::nodeManager::theDegree [protected] |
Tree degree.
Referenced by lti::tree< T >::nodeManager::createNode().
std::vector<node*> lti::tree< T >::nodeManager::theNodes [protected] |
The container vector of all nodes of the tree.
Referenced by lti::tree< T >::nodeManager::createNode(), lti::tree< T >::nodeManager::freeNode(), and lti::tree< T >::nodeManager::getNode().
int lti::tree< T >::nodeManager::theSize [protected] |
Number of valid nodes.
Referenced by lti::tree< T >::nodeManager::createNode(), lti::tree< T >::nodeManager::freeNode(), and lti::tree< T >::nodeManager::size().