34 #ifndef GRAPH_TREE_BASE_H 35 #define GRAPH_TREE_BASE_H 56 typedef std::list<BaseTree *>::iterator
iterator;
66 BaseTree(
bool allowsChildren =
true );
69 const std::list<BaseTree *> & children()
const;
71 bool getAllowsChildren()
const;
73 BaseTree* getChildAt(
unsigned childIndex )
const;
75 int getIndex(
BaseTree* node )
const;
81 const BaseTree* getTopParent()
const;
86 void insert(
BaseTree* child,
int index=-1 );
88 void remove(
unsigned index );
92 void removeFromParent();
94 void setParent(
BaseTree* newParent );
104 virtual size_t size() const
105 __attribute__((__deprecated__("use childrenSize() for the number of children")));
107 virtual
size_t childrenSize() const;
108 const_iterator begin() const;
109 const_iterator end() const;
110 const_reverse_iterator rbegin() const;
111 const_reverse_iterator rend() const;
117 bool _allowsChildren;
126 : _allowsChildren( allowsChildren ), _parent( 0 )
133 return _allowsChildren;
142 for( i=0, it=_children.begin(); i<childIndex && it!=_children.end();
144 if( it != _children.end() )
return *it;
151 return _children.size();
157 return _children.size();
169 return _children.size() == 0;
175 return _children.begin();
181 return _children.end();
187 return _children.rbegin();
193 return _children.rend();
199 if( getParent() ) getParent()->remove(
this );
std::list< BaseTree * >::const_reverse_iterator const_reverse_iterator
BaseTree * getParent() const
Returns the parent BaseTree of the receiver.
void setParent(BaseTree *newParent)
Sets the parent of the receiver to newParent.
virtual size_t childrenSize() const
Returns the number of children BaseTree the receiver contains.
virtual size_t size() const __attribute__((__deprecated__("use childrenSize() for the number of children")))
deprecated - use childrenSize() for the number of children.
const_reverse_iterator rbegin() const
std::list< BaseTree * >::const_iterator const_iterator
std::list< BaseTree * >::iterator iterator
const_iterator end() const
const_iterator begin() const
bool getAllowsChildren() const
Returns true if the receiver allows children.
BaseTree * getChildAt(unsigned childIndex) const
Returns the child BaseTree pointer at index childIndex.
void removeFromParent()
Removes the receiver from its parent.
bool isLeaf() const
Returns true if the receiver is a leaf (terminal node)
std::list< BaseTree * >::reverse_iterator reverse_iterator
const_reverse_iterator rend() const