Public Types | Public Member Functions | Private Attributes

mln::util::tree_node< T > Class Template Reference

Class of generic tree_node for tree. More...

#include <tree.hh>

List of all members.

Public Types

typedef std::vector< tree_node
< T > * > 
children_t

Public Member Functions

tree_node< T > * add_child (T elt)
 Create a tree_node with elt which become the child of the current tree_node.
tree_node< T > * add_child (tree_node< T > *tree_node)
 Bind tree_node to the current tree_node and become its child.
bool check_consistency ()
 Check the consistency of the tree_node.
children_tchildren ()
 The getter of the children.
const children_tchildren () const
 The getter of the children.
tree_node< T > * delete_tree_node ()
 Delete the current tree_node.
T & elt ()
 The getter of the element.
const T & elt () const
 The const getter of the element.
tree_node< T > * parent ()
 The getter of the parent.
void print (std::ostream &ostr, int level=0)
 Print on ostr the arborescence with the current tree_node as root.
tree_node< T > * search (T &elt)
 Search the tree_node with value elt in the arborescence of the current tree_node.
int search_rec (tree_node< T > **res, T &elt)
 The using method for method search.
void set_parent (tree_node< T > *parent)
 Bind tree_node to the current tree_node and become its parent.
 tree_node ()
 Constructor.
 tree_node (T elt)
 Constructor.

Private Attributes

std::vector< tree_node< T > * > child_
 The children.
elt_
 The value.
tree_node< T > * parent_
 The tree_node parent.

Detailed Description

template<typename T>
class mln::util::tree_node< T >

Class of generic tree_node for tree.

Definition at line 58 of file tree.hh.


Member Typedef Documentation

template<typename T>
typedef std::vector< tree_node<T>* > mln::util::tree_node< T >::children_t

Definition at line 62 of file tree.hh.


Constructor & Destructor Documentation

template<typename T >
mln::util::tree_node< T >::tree_node (  )  [inline]

Constructor.

Definition at line 345 of file tree.hh.

template<typename T >
mln::util::tree_node< T >::tree_node ( elt  )  [inline]

Constructor.

Parameters:
[in] elt The element of tree_node.

Definition at line 352 of file tree.hh.


Member Function Documentation

template<typename T >
tree_node< T > * mln::util::tree_node< T >::add_child ( elt  )  [inline]

Create a tree_node with elt which become the child of the current tree_node.

Parameters:
[in] elt The element of the new child to add.
Returns:
The new tree_node created.

Definition at line 394 of file tree.hh.

References mln::util::tree_node< T >::child_, and mln::util::tree_node< T >::parent_.

template<typename T >
tree_node< T > * mln::util::tree_node< T >::add_child ( tree_node< T > *  tree_node  )  [inline]

Bind tree_node to the current tree_node and become its child.

Parameters:
[in] tree_node The new child tree_node.
Returns:
The child tree_node.

Definition at line 407 of file tree.hh.

References mln::util::tree_node< T >::children(), mln::util::tree_node< T >::parent(), and mln::util::tree_node< T >::parent_.

template<typename T >
bool mln::util::tree_node< T >::check_consistency (  )  [inline]

Check the consistency of the tree_node.

Returns:
true if no error, else false.

Definition at line 519 of file tree.hh.

References mln::util::tree_node< T >::child_.

template<typename T >
const std::vector< tree_node< T > * > & mln::util::tree_node< T >::children (  )  const [inline]

The getter of the children.

Returns:
The children of the tree_node in const.

Definition at line 386 of file tree.hh.

References mln::util::tree_node< T >::child_.

template<typename T >
std::vector< tree_node< T > * > & mln::util::tree_node< T >::children (  )  [inline]
template<typename T >
tree_node< T > * mln::util::tree_node< T >::delete_tree_node (  )  [inline]

Delete the current tree_node.

Definition at line 427 of file tree.hh.

References mln::util::tree_node< T >::child_, and mln::util::tree_node< T >::parent_.

template<typename T >
const T & mln::util::tree_node< T >::elt (  )  const [inline]

The const getter of the element.

Returns:
The element of the tree_node in const.

Definition at line 361 of file tree.hh.

References mln::util::tree_node< T >::elt_.

template<typename T >
T & mln::util::tree_node< T >::elt (  )  [inline]
template<typename T >
tree_node< T > * mln::util::tree_node< T >::parent (  )  [inline]

The getter of the parent.

Returns:
The parent of the tree_node.

Definition at line 477 of file tree.hh.

References mln::util::tree_node< T >::parent_.

Referenced by mln::util::tree_node< T >::add_child(), mln::util::branch_iter_ind< T >::deepness(), and mln::util::branch_iter< T >::deepness().

template<typename T >
void mln::util::tree_node< T >::print ( std::ostream &  ostr,
int  level = 0 
) [inline]

Print on ostr the arborescence with the current tree_node as root.

Parameters:
[in] ostr The output stream.
[in] level The deep level

Definition at line 449 of file tree.hh.

References mln::util::tree_node< T >::child_, and mln::util::tree_node< T >::elt().

template<typename T >
tree_node< T > * mln::util::tree_node< T >::search ( T &  elt  )  [inline]

Search the tree_node with value elt in the arborescence of the current tree_node.

Parameters:
[in] elt The value of the searched tree_node.
Returns:
If not found 0 else the tree_node with elt value.

Definition at line 507 of file tree.hh.

References mln::util::tree_node< T >::search_rec().

template<typename T >
int mln::util::tree_node< T >::search_rec ( tree_node< T > **  res,
T &  elt 
) [inline]

The using method for method search.

Definition at line 485 of file tree.hh.

References mln::util::tree_node< T >::child_, and mln::util::tree_node< T >::elt_.

Referenced by mln::util::tree_node< T >::search().

template<typename T >
void mln::util::tree_node< T >::set_parent ( tree_node< T > *  parent  )  [inline]

Bind tree_node to the current tree_node and become its parent.

Parameters:
[in] parent The new parent tree_node.

Definition at line 467 of file tree.hh.

References mln::util::tree_node< T >::child_, and mln::util::tree_node< T >::parent_.


Member Data Documentation

template<typename T>
std::vector< tree_node<T>* > mln::util::tree_node< T >::child_ [private]
template<typename T>
T mln::util::tree_node< T >::elt_ [private]

The value.

Definition at line 172 of file tree.hh.

Referenced by mln::util::tree_node< T >::elt(), and mln::util::tree_node< T >::search_rec().

template<typename T>
tree_node<T>* mln::util::tree_node< T >::parent_ [private]