Templated Binary Search Tree
Public Member Functions | Public Attributes | List of all members
Node< T > Struct Template Reference

Public Member Functions

 Node (const T &_data)
 Custom constructor.
 
 Node ()
 Default constructor.
 
 ~Node ()=default
 Default-generated destructor.
 
 Node (const T &_data, Node< T > *_parent) noexcept
 Copy constructor.
 
 Node (const std::unique_ptr< Node< T >> &ptn, Node< T > *_parent)
 Helper recursive function that, starting from a Node and its parent, copy all the tree recursively. More...
 
void print ()
 Move constructor. More...
 

Public Attributes

data
 Data to be stored in the Node.
 
std::unique_ptr< Node< T > > left
 Unique pointer to the left child.
 
std::unique_ptr< Node< T > > right
 Unique pointer to the right child.
 
Node< T > * parent
 Raw pointer to the parent Node.
 

Constructor & Destructor Documentation

◆ Node()

template<typename T >
Node< T >::Node ( const std::unique_ptr< Node< T >> &  ptn,
Node< T > *  _parent 
)
inline

Helper recursive function that, starting from a Node and its parent, copy all the tree recursively.

Parameters
ptnReference to a unique_ptr to a Node
_parentRaw pointer to the parent Node This function exploit the std::make_unique() function, to construct an object of type Node and wraps it into a unique_ptr.

Member Function Documentation

◆ print()

template<typename T >
void Node< T >::print ( )
inline

Move constructor.

Simple void function that prints a Node. Used just for testing.


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