23 #ifndef ATBBASICTREE_HH 24 #define ATBBASICTREE_HH 37 template<
typename KeyT,
typename ContentT>
44 : _key(key), _content(
content), p_parent(NULL), _children(),
50 while (_children.size() > 0)
51 _children.front()->reparent(p_parent);
55 KeyT
const key()
const 85 std::list<BasicTreeNode<KeyT, ContentT>*>
const &
children()
const 90 std::list<BasicTreeNode<KeyT, ContentT>*> &
children()
107 if (p_parent == parent)
return;
108 if (p_parent != NULL) p_parent->_removeChild(
this);
110 if (parent != NULL) parent->_addChild(
this);
128 _children.remove(child);
133 _children.push_back(child);
138 if (p_parent == NULL) p_root =
this;
139 else p_root = p_parent->p_root;
141 it = _children.begin(); it != _children.end(); ++it)
142 (*it)->_updateRoot();
149 std::list<BasicTreeNode<KeyT, ContentT>*> _children;
155 template<
typename KeyT,
typename ContentT>
159 os << n.
key() <<
" ( ";
160 typename std::list<BasicTreeNode<KeyT, ContentT>*>::const_iterator it;
void setContent(const ContentT &content)
BasicTreeNode< KeyT, ContentT > const * parent() const
std::ostream & operator<<(std::ostream &os, BasicTreeNode< KeyT, ContentT > const &n)
void reparent(BasicTreeNode< KeyT, ContentT > *parent)
BasicTreeNode(KeyT const &key, ContentT const &content=ContentT())
BasicTreeNode< KeyT, ContentT > const * root() const
BasicTreeNode< KeyT, ContentT > * parent()
std::list< BasicTreeNode< KeyT, ContentT > * > & children()
std::list< BasicTreeNode< KeyT, ContentT > * > const & children() const
void addChild(BasicTreeNode< KeyT, ContentT > *child)
BasicTreeNode< KeyT, ContentT > * root()
void setKey(const KeyT &key)
ContentT const content() const
void removeChild(BasicTreeNode< KeyT, ContentT > *child)