Sayonara Player
Public Member Functions | Public Attributes | List of all members
SP::Tree< T > Class Template Reference

#include <Tree.h>

Detailed Description

template<typename T>
class SP::Tree< T >

The Tree class.

Public Member Functions

 Tree (const T &data_)
 Tree constructor. More...
 
Treecopy ()
 
Treeadd_child (Tree *node)
 adds a child to the given node More...
 
Treeadd_child (const T &data)
 
Treeremove_child (Tree *deleted_node)
 remove a node from the current node More...
 
void move (Tree *new_parent)
 move current node to a new parent More...
 
void sort (bool recursive)
 sort children of all nodes in ascending way according to their data More...
 

Public Attributes

Treeparent =nullptr
 
data
 
QList< Tree * > children
 

Constructor & Destructor Documentation

◆ Tree()

template<typename T >
SP::Tree< T >::Tree ( const T &  data_)
inline

Tree constructor.

Parameters
data_set the root element

Member Function Documentation

◆ add_child()

template<typename T >
Tree* SP::Tree< T >::add_child ( Tree< T > *  node)
inline

adds a child to the given node

Parameters
nodethe parent node
Returns
pointer to inserted node

◆ copy()

template<typename T >
Tree* SP::Tree< T >::copy ( )
inline

copy the entire tree. Has to be deleted afterwards

◆ move()

template<typename T >
void SP::Tree< T >::move ( Tree< T > *  new_parent)
inline

move current node to a new parent

Parameters
new_parentnew parent of node

◆ remove_child()

template<typename T >
Tree* SP::Tree< T >::remove_child ( Tree< T > *  deleted_node)
inline

remove a node from the current node

Parameters
deleted_nodenode to remove
Returns
pointer to deleted_node

◆ sort()

template<typename T >
void SP::Tree< T >::sort ( bool  recursive)
inline

sort children of all nodes in ascending way according to their data

Parameters
recursiveif set to true, do it for all subnodes, too