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

The Tree class a class to contain a TreeNode*. More...

#include <Tree.h>

Public Member Functions

 Tree ()
 Tree Default Constructor.
 
 Tree (TreeNode< Item > *root)
 Tree Constructor. More...
 
 Tree (const Tree< Item > &T)
 Tree Copy Constructor. More...
 
 ~Tree ()
 ~Tree Destructor
 
Tree< Item > & operator= (const Tree< Item > &T)
 operator = assignment operator More...
 
void addHere (const Item &item)
 addHere Adds an item as a child to the current node More...
 
void addNode (TreeNode< Item > *parent, const Item &item)
 addNode Adds an item as a child to the parent More...
 
TreeNode< Item > * search (const Item &item)
 search searches for a specific item More...
 
bool inTree (TreeNode< Item > *node)
 inTree Checks if the node is part of the tree More...
 
bool empty () const
 empty Checks if the tree is empty More...
 
void clear ()
 clear Clears the tree
 
std::size_t leafNum ()
 leafNum Counts the number of leaves in the tree More...
 
TreeNode< Item > * getParent (TreeNode< Item > *branch)
 getParent Gets the parent of the branch More...
 
TreeNode< Item > * getCurrent ()
 getCurrent Returns the current node pointer More...
 
void set (const Item &item)
 set Set the item of the current node More...
 
void shiftToRoot ()
 shiftToRoot shift the current to the root
 
void shiftUp ()
 shiftUp Shift the current to its parent
 
void shiftDown (std::size_t child)
 shiftDown Shift the current to one of its children More...
 
void shiftTo (TreeNode< Item > *target)
 shiftTo Shift the current to the specified target More...
 
bool hasParent ()
 hasParent Checks if current has a parent More...
 
bool hasChild ()
 hasChild Checks if current has children More...
 
std::size_t childNum ()
 childNum Finds the number of children of current More...
 
Item & get ()
 get Returns the item of current More...
 
std::size_t size () const
 size Returns the size of the tree More...
 
std::vector< TreeNode< Item > * > getLeaves ()
 getLeaves Returns a vector of the leaves of the tree More...
 

Protected Attributes

TreeNode< Item > * _root
 _root the root of the tree
 
TreeNode< Item > * _current
 _current the treenode in which many operations are performed. Can be changed via shift functions
 

Friends

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

Detailed Description

template<typename Item>
class Tree< Item >

The Tree class a class to contain a TreeNode*.

Constructor & Destructor Documentation

template<typename Item>
Tree< Item >::Tree ( TreeNode< Item > *  root)
inline

Tree Constructor.

Parameters
rootSets the root to this root NOTE: Does not copy the root
template<typename Item>
Tree< Item >::Tree ( const Tree< Item > &  T)
inline

Tree Copy Constructor.

Parameters
Ta Tree NOTE: Copies the root of T

Member Function Documentation

template<typename Item>
void Tree< Item >::addHere ( const Item &  item)
inline

addHere Adds an item as a child to the current node

Parameters
itemthe item to add
template<typename Item>
void Tree< Item >::addNode ( TreeNode< Item > *  parent,
const Item &  item 
)
inline

addNode Adds an item as a child to the parent

Parameters
parentthe parent
itemthe item
template<typename Item>
std::size_t Tree< Item >::childNum ( )
inline

childNum Finds the number of children of current

Returns
the number of children
template<typename Item>
bool Tree< Item >::empty ( ) const
inline

empty Checks if the tree is empty

Returns
True if it is empty, False otherwise
template<typename Item>
Item& Tree< Item >::get ( )
inline

get Returns the item of current

Returns
the item reference
template<typename Item>
TreeNode<Item>* Tree< Item >::getCurrent ( )
inline

getCurrent Returns the current node pointer

Returns
current node pointer
template<typename Item>
std::vector<TreeNode<Item>*> Tree< Item >::getLeaves ( )
inline

getLeaves Returns a vector of the leaves of the tree

Returns
the vector of leaves
template<typename Item>
TreeNode<Item>* Tree< Item >::getParent ( TreeNode< Item > *  branch)
inline

getParent Gets the parent of the branch

Parameters
branchthe branch
Returns
nullptr if there is no parent OR the branch is no part of the tree, The parent if found
template<typename Item>
bool Tree< Item >::hasChild ( )
inline

hasChild Checks if current has children

Returns
True if it does, False otherwise
template<typename Item>
bool Tree< Item >::hasParent ( )
inline

hasParent Checks if current has a parent

Returns
True if it does, False otherwise
template<typename Item>
bool Tree< Item >::inTree ( TreeNode< Item > *  node)
inline

inTree Checks if the node is part of the tree

Parameters
nodethe node
Returns
True if it is in the tree, False otherwise
template<typename Item>
std::size_t Tree< Item >::leafNum ( )
inline

leafNum Counts the number of leaves in the tree

Returns
number of leaves
template<typename Item>
Tree<Item>& Tree< Item >::operator= ( const Tree< Item > &  T)
inline

operator = assignment operator

Parameters
TTree
Returns
this
template<typename Item>
TreeNode<Item>* Tree< Item >::search ( const Item &  item)
inline

search searches for a specific item

Parameters
itemthe target
Returns
nullptr if not found, or the pointer to the node
template<typename Item>
void Tree< Item >::set ( const Item &  item)
inline

set Set the item of the current node

Parameters
itemthe item
template<typename Item>
void Tree< Item >::shiftDown ( std::size_t  child)
inline

shiftDown Shift the current to one of its children

Parameters
childthe child to shift to NOTE: Does not change current if the child does not exist
template<typename Item>
void Tree< Item >::shiftTo ( TreeNode< Item > *  target)
inline

shiftTo Shift the current to the specified target

Parameters
targetthe target NOTE: Does not change current if the target is not part of the tree
template<typename Item>
std::size_t Tree< Item >::size ( ) const
inline

size Returns the size of the tree

Returns
the size

Friends And Related Function Documentation

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

operator << insertion

Parameters
outoutput stream
TTree
Returns
output stream

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