Natural Language Processing  0.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
TreeNode< Item > Struct Template Reference

The TreeNode struct the node that will occupy trees. More...

#include <Tree.h>

Public Types

typedef std::vector< TreeNode * > TNvector
 TNvector typedef of std::vector<TreeNode*>
 

Public Member Functions

 TreeNode (const Item &data=Item(), const TNvector &children=TNvector())
 TreeNode Constructor. More...
 
 ~TreeNode ()
 ~TreeNode destructor for TreeNode. Destroys all of its children.
 
Item & data ()
 data returns a reference to the item More...
 
TNvectorchildren ()
 children returns a reference to the children vector More...
 
void setData (const Item &data)
 setData changes the item More...
 
void setChildren (const TNvector &children)
 setChildren changes the children More...
 
void addChild (const Item &data)
 addChild adds a child to the vector More...
 
Item data () const
 data returns a non reference item More...
 
TNvector children () const
 children returns a non reference vector More...
 
bool isLeaf () const
 isLeaf checks if the node is a leaf, i.e. has no children More...
 

Public Attributes

Item _data
 _data the item inside the node
 
TNvector _child
 _child a vector of children whose parent is this node
 

Friends

std::ostream & operator<< (std::ostream &out, const TreeNode< Item > &T)
 operator << insertion More...
 

Detailed Description

template<typename Item>
struct TreeNode< Item >

The TreeNode struct the node that will occupy trees.

Constructor & Destructor Documentation

template<typename Item>
TreeNode< Item >::TreeNode ( const Item &  data = Item(),
const TNvector children = TNvector() 
)
inline

TreeNode Constructor.

Parameters
dataitem, by default it is the Default Constructor for the Item Type
childrenthe children, by default it is any empty vector

Member Function Documentation

template<typename Item>
void TreeNode< Item >::addChild ( const Item &  data)
inline

addChild adds a child to the vector

Parameters
datathe new child item
template<typename Item>
TNvector& TreeNode< Item >::children ( )
inline

children returns a reference to the children vector

Returns
vector reference
template<typename Item>
TNvector TreeNode< Item >::children ( ) const
inline

children returns a non reference vector

Returns
non reference vector
template<typename Item>
Item& TreeNode< Item >::data ( )
inline

data returns a reference to the item

Returns
item reference
template<typename Item>
Item TreeNode< Item >::data ( ) const
inline

data returns a non reference item

Returns
non reference item
template<typename Item>
bool TreeNode< Item >::isLeaf ( ) const
inline

isLeaf checks if the node is a leaf, i.e. has no children

Returns
True for is a Leaf, False for is not a leaf
template<typename Item>
void TreeNode< Item >::setChildren ( const TNvector children)
inline

setChildren changes the children

Parameters
childrenthe new children NOTE: Does not clean up any dynamic items it may hold.
template<typename Item>
void TreeNode< Item >::setData ( const Item &  data)
inline

setData changes the item

Parameters
datathe new item

Friends And Related Function Documentation

template<typename Item>
std::ostream& operator<< ( std::ostream &  out,
const TreeNode< Item > &  T 
)
friend

operator << insertion

Parameters
outoutput stream
Tthe TreeNode
Returns
the output stream

The documentation for this struct was generated from the following file: