|
CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
|
A tree structure with any number of children. More...
#include <tree.hpp>
Public Types | |
| typedef T | value_type |
| The type of the value stored in the nodes. | |
| typedef tree< T > | self_type |
| The type of the current class. | |
| typedef child_list::iterator | iterator |
| typedef child_list::const_iterator | const_iterator |
Public Member Functions | |
| tree () | |
| Default constructor. | |
| tree (const T &that) | |
| Constructor with initialization. | |
| bool | operator== (const self_type &that) const |
| Equality operator. | |
| bool | is_leaf () const |
| Tell if this node is a leaf (ie. it has no child). | |
| self_type & | add_child (const T &v) |
| Add a child to this node. | |
| self_type & | add_child (const self_type &v) |
| Add a child subtree to this node. | |
| iterator | find (const T &v) |
| Search the first child having a given value. | |
| const_iterator | find (const T &v) const |
| Search the first child having a given value. | |
| iterator | begin () |
| Get an iterator on the begining of the children. | |
| iterator | end () |
| Get an iterator just past the end of the children. | |
| const_iterator | begin () const |
| Get a constant iterator on the begining of the children. | |
| const_iterator | end () const |
| Get a constant iterator just past the end of the children. | |
Public Attributes | |
| T | value |
| The value in this node. | |
Private Types | |
| typedef std::list< tree< T > > | child_list |
| The type of the list in which are stored the children. | |
Private Attributes | |
| child_list | m_child |
| The children of this node. | |
A tree structure with any number of children.
typedef std::list< tree<T> > claw::tree< T >::child_list [private] |
| typedef child_list::const_iterator claw::tree< T >::const_iterator |
| typedef child_list::iterator claw::tree< T >::iterator |
| typedef tree<T> claw::tree< T >::self_type |
| typedef T claw::tree< T >::value_type |
| claw::tree< T >::tree | ( | ) |
| claw::tree< T >::tree | ( | const T & | v | ) | [explicit] |
| claw::tree< T >::self_type & claw::tree< T >::add_child | ( | const T & | v | ) |
| claw::tree< T >::self_type & claw::tree< T >::add_child | ( | const self_type & | v | ) |
| claw::tree< T >::const_iterator claw::tree< T >::begin | ( | ) | const |
Get a constant iterator on the begining of the children.
Definition at line 180 of file tree.tpp.
{
return const_iterator( m_child.begin() );
} // tree::begin()
| claw::tree< T >::iterator claw::tree< T >::begin | ( | ) |
Get an iterator on the begining of the children.
Definition at line 160 of file tree.tpp.
Referenced by claw::tree< T >::operator==().
| claw::tree< T >::iterator claw::tree< T >::end | ( | ) |
| claw::tree< T >::const_iterator claw::tree< T >::end | ( | ) | const |
Get a constant iterator just past the end of the children.
Definition at line 190 of file tree.tpp.
{
return const_iterator( m_child.end() );
} // tree::end()
| claw::tree< T >::iterator claw::tree< T >::find | ( | const T & | v | ) |
Search the first child having a given value.
| v | The value of the child to find. |
| claw::tree< T >::const_iterator claw::tree< T >::find | ( | const T & | v | ) | const |
Search the first child having a given value.
| v | The value of the child to find. |
Definition at line 141 of file tree.tpp.
{
typename child_list::const_iterator it;
bool found = false;
for ( it=m_child.begin(); !found && (it!=end()) ; )
if ( it->value == v )
found = true;
else
++it;
return const_iterator( it );
} // tree::find()
| bool claw::tree< T >::is_leaf | ( | ) | const |
| bool claw::tree< T >::operator== | ( | const self_type & | that | ) | const |
Equality operator.
| that | The tree to compare to. |
Definition at line 60 of file tree.tpp.
References claw::tree< T >::begin(), claw::tree< T >::m_child, and claw::tree< T >::value.
{
bool result = ( value == that.value );
if (result)
{
typename child_list::const_iterator it_me = m_child.begin();
typename child_list::const_iterator it_him = that.m_child.begin();
typename child_list::const_iterator eit_me = m_child.end();
typename child_list::const_iterator eit_him = that.m_child.end();
while ( result && (it_me!=eit_me) && (it_him!=eit_him) )
result = (*it_me == *it_him);
if ( (it_me!=eit_me) || (it_him!=eit_him) )
result = false;
}
return result;
} // tree::operator==()
child_list claw::tree< T >::m_child [private] |
The children of this node.
Definition at line 85 of file tree.hpp.
Referenced by claw::tree< T >::operator==().
| T claw::tree< T >::value |
The value in this node.
Definition at line 81 of file tree.hpp.
Referenced by claw::tree< T >::operator==().
1.7.3