Kale
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Kale::Tree< T >::Child Struct Reference

#include <Tree.hpp>

Public Member Functions

 Child (Tree &tree)
 
 Child (Tree &tree, const T &value)
 
 Child (Child &parent)
 
 Child (Child &parent, const T &value)
 
 ~Child ()
 
 Child (const Child &other)=delete
 
 Child (Child &&other)=delete
 
void operator= (const Child &other)=delete
 
void operator= (Child &&other)=delete
 
ChildaddChild ()
 
ChildaddChild (const T &value)
 
void removeChild (size_t horizontal)
 
const Toperator-> () const
 
Toperator-> ()
 
const TgetValue () const
 
TgetValue ()
 
const ChildgetNext () const
 
ChildgetNext ()
 
const ChildgetPrevious () const
 
ChildgetPrevious ()
 
const ChildgetParent () const
 
ChildgetParent ()
 
size_t getHorizontalIndex () const
 
size_t getVerticalIndex () const
 
const std::list< Child > & getChildren () const
 
std::list< Child > & getChildren ()
 

Private Member Functions

void setup ()
 

Private Attributes

Childnext = nullptr
 
Childprevious = nullptr
 
Childparent = nullptr
 
Treetree
 
std::list< Childchildren
 
size_t horizontal
 
size_t vertical
 
T value
 

Friends

class Tree< T >
 

Detailed Description

template<typename T>
struct Kale::Tree< T >::Child

Represents a single child in the tree

Definition at line 36 of file Tree.hpp.

Constructor & Destructor Documentation

◆ Child() [1/6]

template<typename T >
Kale::Tree< T >::Child::Child ( Tree & tree)
inline

Constructs a new child at the tree root

Note
Do not call the constructor manually, instead use addChild.
Parameters
treeThe tree this child belongs to

Definition at line 138 of file Tree.hpp.

◆ Child() [2/6]

template<typename T >
Kale::Tree< T >::Child::Child ( Tree & tree,
const T & value )
inline

Constructs a new child at the root of a tree given a value

Note
Do not call the constructor manually, instead use addChild.
Parameters
treeThe tree this child belongs to
valueThe value to initialize the root to

Definition at line 146 of file Tree.hpp.

◆ Child() [3/6]

template<typename T >
Kale::Tree< T >::Child::Child ( Child & parent)
inline

Constructs a new child given a parent using the value default constructor

Note
Do not call the constructor manually, instead use addChild.
Parameters
parentThe parent of this node

Definition at line 153 of file Tree.hpp.

◆ Child() [4/6]

template<typename T >
Kale::Tree< T >::Child::Child ( Child & parent,
const T & value )
inline

Constructs a new child given a parent and a given value

Note
Do not call the constructor manually, instead use addChild.
Parameters
parentThe parent
valueThe value to set the node to

Definition at line 163 of file Tree.hpp.

◆ ~Child()

template<typename T >
Kale::Tree< T >::Child::~Child ( )
inline

Does cleanup and updates indices

Definition at line 170 of file Tree.hpp.

◆ Child() [5/6]

template<typename T >
Kale::Tree< T >::Child::Child ( const Child & other)
delete

◆ Child() [6/6]

template<typename T >
Kale::Tree< T >::Child::Child ( Child && other)
delete

Member Function Documentation

◆ addChild() [1/2]

template<typename T >
Child & Kale::Tree< T >::Child::addChild ( )
inline

Adds a child node under this child node using the value's default constructor

Definition at line 190 of file Tree.hpp.

◆ addChild() [2/2]

template<typename T >
Child & Kale::Tree< T >::Child::addChild ( const T & value)
inline

Adds a child node under this child node

Parameters
valueThe value to set the child to

Definition at line 198 of file Tree.hpp.

◆ getChildren() [1/2]

template<typename T >
std::list< Child > & Kale::Tree< T >::Child::getChildren ( )
inline

Gets a list of the children of this branch of the tree, a vertical level above this node

Returns
A list of the children of this branch of the tree, a vertical level above this node

Definition at line 318 of file Tree.hpp.

◆ getChildren() [2/2]

template<typename T >
const std::list< Child > & Kale::Tree< T >::Child::getChildren ( ) const
inline

Gets a list of the children of this branch of the tree, a vertical level above this node

Returns
A list of the children of this branch of the tree, a vertical level above this node

Definition at line 310 of file Tree.hpp.

◆ getHorizontalIndex()

template<typename T >
size_t Kale::Tree< T >::Child::getHorizontalIndex ( ) const
inline

Gets the horizontal index of this node, horizontal indices start at zero and increment until next is nullptr

Returns
The horizontal index of this node, horizontal indices start at zero and increment until next is nullptr

Definition at line 294 of file Tree.hpp.

◆ getNext() [1/2]

template<typename T >
Child * Kale::Tree< T >::Child::getNext ( )
inline

Gets a pointer to the next node at the same vertical level, or nullptr if this is the last

Returns
A pointer to the next node at the same vertical level, or nullptr if this is the last

Definition at line 254 of file Tree.hpp.

◆ getNext() [2/2]

template<typename T >
const Child * Kale::Tree< T >::Child::getNext ( ) const
inline

Gets a pointer to the next node at the same vertical level, or nullptr if this is the last

Returns
A pointer to the next node at the same vertical level, or nullptr if this is the last

Definition at line 246 of file Tree.hpp.

◆ getParent() [1/2]

template<typename T >
Child * Kale::Tree< T >::Child::getParent ( )
inline

Gets a pointer to the parent of this node, a vertical level below this node.

Returns
A pointer to the parent of this node, a vertical level below this node.

Definition at line 286 of file Tree.hpp.

◆ getParent() [2/2]

template<typename T >
const Child * Kale::Tree< T >::Child::getParent ( ) const
inline

Gets a pointer to the parent of this node, a vertical level below this node.

Returns
A pointer to the parent of this node, a vertical level below this node.

Definition at line 278 of file Tree.hpp.

◆ getPrevious() [1/2]

template<typename T >
Child * Kale::Tree< T >::Child::getPrevious ( )
inline

Gets a pointer to the previous node at the same vertical level, or nullptr if this is the first

Returns
A pointer to the previous node at the same vertical level, or nullptr if this is the first

Definition at line 270 of file Tree.hpp.

◆ getPrevious() [2/2]

template<typename T >
const Child * Kale::Tree< T >::Child::getPrevious ( ) const
inline

Gets a pointer to the previous node at the same vertical level, or nullptr if this is the first

Returns
A pointer to the previous node at the same vertical level, or nullptr if this is the first

Definition at line 262 of file Tree.hpp.

◆ getValue() [1/2]

template<typename T >
T & Kale::Tree< T >::Child::getValue ( )
inline

Allows for accessing the held value's methods or members

Returns
A reference to the value

Definition at line 238 of file Tree.hpp.

◆ getValue() [2/2]

template<typename T >
const T & Kale::Tree< T >::Child::getValue ( ) const
inline

Allows for accessing the held value's methods or members

Returns
A reference to the value

Definition at line 230 of file Tree.hpp.

◆ getVerticalIndex()

template<typename T >
size_t Kale::Tree< T >::Child::getVerticalIndex ( ) const
inline

Gets the vertical index of this node, the root is 0 and it increments as you loop through more children

Returns
The vertical index of this node, the root is 0 and it increments as you loop through more children

Definition at line 302 of file Tree.hpp.

◆ operator->() [1/2]

template<typename T >
T * Kale::Tree< T >::Child::operator-> ( )
inline

Allows for accessing the held value's methods or members

Returns
A pointer to the value

Definition at line 222 of file Tree.hpp.

◆ operator->() [2/2]

template<typename T >
const T * Kale::Tree< T >::Child::operator-> ( ) const
inline

Allows for accessing the held value's methods or members

Returns
A pointer to the value

Definition at line 214 of file Tree.hpp.

◆ operator=() [1/2]

template<typename T >
void Kale::Tree< T >::Child::operator= ( Child && other)
delete

◆ operator=() [2/2]

template<typename T >
void Kale::Tree< T >::Child::operator= ( const Child & other)
delete

◆ removeChild()

template<typename T >
void Kale::Tree< T >::Child::removeChild ( size_t horizontal)
inline

Removes a child node from this branch

Parameters
horizontalThe horizontal index of the child

Definition at line 206 of file Tree.hpp.

◆ setup()

template<typename T >
void Kale::Tree< T >::Child::setup ( )
inlineprivate

Sets up the next/previous and updates surrounding tree children

Definition at line 82 of file Tree.hpp.

Friends And Related Symbol Documentation

◆ Tree< T >

template<typename T >
friend class Tree< T >
friend

Definition at line 82 of file Tree.hpp.

Member Data Documentation

◆ children

template<typename T >
std::list<Child> Kale::Tree< T >::Child::children
private

A list of the children of this branch of the tree, a vertical level above this node

Definition at line 62 of file Tree.hpp.

◆ horizontal

template<typename T >
size_t Kale::Tree< T >::Child::horizontal
private

The horizontal index of this node, horizontal indices start at zero and increment until next is nullptr

Definition at line 67 of file Tree.hpp.

◆ next

template<typename T >
Child* Kale::Tree< T >::Child::next = nullptr
private

A pointer to the next node at the same vertical level, or nullptr if this is the last

Definition at line 42 of file Tree.hpp.

◆ parent

template<typename T >
Child* Kale::Tree< T >::Child::parent = nullptr
private

A pointer to the parent of this node, a vertical level below this node.

Definition at line 52 of file Tree.hpp.

◆ previous

template<typename T >
Child* Kale::Tree< T >::Child::previous = nullptr
private

A pointer to the previous node at the same vertical level, or nullptr if this is the first

Definition at line 47 of file Tree.hpp.

◆ tree

template<typename T >
Tree& Kale::Tree< T >::Child::tree
private

The tree this child belongs to

Definition at line 57 of file Tree.hpp.

◆ value

template<typename T >
T Kale::Tree< T >::Child::value
private

The value held within this tree node

Definition at line 77 of file Tree.hpp.

◆ vertical

template<typename T >
size_t Kale::Tree< T >::Child::vertical
private

The vertical index of this node, the root is 0 and it increments as you loop through more children

Definition at line 72 of file Tree.hpp.


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