Kale
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
Kale::Tree< T > Class Template Reference

#include <Tree.hpp>

Classes

struct  Child
 
struct  RawIterator
 

Public Types

using Iterator = RawIterator<Child>
 
using ConstIterator = RawIterator<const Child>
 

Public Member Functions

 Tree ()
 
 Tree (const T &value)
 
 Tree (Tree &&other)=delete
 
void operator= (Tree &&other)=delete
 
Iterator begin ()
 
ConstIterator cbegin () const
 
Iterator end ()
 
ConstIterator cend () const
 
Childfront ()
 
const Childfront () const
 
Childback ()
 
const Childback () const
 
const Childoperator() (size_t horizontal, size_t vertical) const
 
Childoperator() (size_t horizontal, size_t vertical)
 

Public Attributes

std::unique_ptr< Childroot
 

Private Attributes

ChildbackPtr
 

Friends

struct Child
 
struct RawIterator< Child >
 
struct RawIterator< const Child >
 

Detailed Description

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

Represents a tree based data structure

Template Parameters
TThe structure to be holding in each tree leaf node

Definition at line 30 of file Tree.hpp.

Member Typedef Documentation

◆ ConstIterator

template<typename T >
using Kale::Tree< T >::ConstIterator = RawIterator<const Child>

Custom iterator used for traversing trees with immutable elements

Definition at line 524 of file Tree.hpp.

◆ Iterator

template<typename T >
using Kale::Tree< T >::Iterator = RawIterator<Child>

Custom iterator used for traversing trees with mutable elements

Definition at line 519 of file Tree.hpp.

Constructor & Destructor Documentation

◆ Tree() [1/3]

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

Creates a new tree with a root using the default constructor of the held object

Definition at line 534 of file Tree.hpp.

◆ Tree() [2/3]

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

Creates a new tree with a root with an initialized value

Parameters
valueThe value to initialize the root with

Definition at line 540 of file Tree.hpp.

◆ Tree() [3/3]

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

Member Function Documentation

◆ back() [1/2]

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

Gets the bottom right element of the tree (the last item iterated usually)

Returns
the bottom right element of the tree (the last item iterated)

Definition at line 602 of file Tree.hpp.

◆ back() [2/2]

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

Gets the bottom right element of the tree (the last item iterated usually)

Returns
the bottom right element of the tree (the last item iterated)

Definition at line 610 of file Tree.hpp.

◆ begin()

template<typename T >
Iterator Kale::Tree< T >::begin ( )
inline

Gets the root as an iterator to allow for traversal of the tree

Returns
The root as an iterator to allow for traversal of the tree

Definition at line 553 of file Tree.hpp.

◆ cbegin()

template<typename T >
ConstIterator Kale::Tree< T >::cbegin ( ) const
inline

Gets the root as a const iterator to allow for traversal of the tree

Returns
The root as a const iterator to allow for traversal of the tree

Definition at line 561 of file Tree.hpp.

◆ cend()

template<typename T >
ConstIterator Kale::Tree< T >::cend ( ) const
inline

Gets an invalid constant iterator after the last child to allow for traversal of the tree

Returns
An invalid constant iterator after the last child to allow for traversal of the tree

Definition at line 577 of file Tree.hpp.

◆ end()

template<typename T >
Iterator Kale::Tree< T >::end ( )
inline

Gets an invalid iterator after the last child to allow for traversal of the tree

Returns
An invalid iterator after the last child to allow for traversal of the tree

Definition at line 569 of file Tree.hpp.

◆ front() [1/2]

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

Gets the root of the tree

Returns
The root of the tree

Definition at line 586 of file Tree.hpp.

◆ front() [2/2]

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

Gets the root of the tree

Returns
The root of the tree

Definition at line 594 of file Tree.hpp.

◆ operator()() [1/2]

template<typename T >
Child & Kale::Tree< T >::operator() ( size_t horizontal,
size_t vertical )
inline

Accesses a child element given the horizontal and vertical indices of the child

Parameters
horizontalThe horizontal index of the child
verticalThe vertical index of the child
Returns
The child

Definition at line 632 of file Tree.hpp.

◆ operator()() [2/2]

template<typename T >
const Child & Kale::Tree< T >::operator() ( size_t horizontal,
size_t vertical ) const
inline

Accesses a child element given the horizontal and vertical indices of the child

Parameters
horizontalThe horizontal index of the child
verticalThe vertical index of the child
Returns
The child

Definition at line 620 of file Tree.hpp.

◆ operator=()

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

Friends And Related Symbol Documentation

◆ Child

template<typename T >
friend struct Child
friend

Definition at line 510 of file Tree.hpp.

◆ RawIterator< Child >

template<typename T >
friend struct RawIterator< Child >
friend

Definition at line 510 of file Tree.hpp.

◆ RawIterator< const Child >

template<typename T >
friend struct RawIterator< const Child >
friend

Definition at line 510 of file Tree.hpp.

Member Data Documentation

◆ backPtr

template<typename T >
Child* Kale::Tree< T >::backPtr
private

Pointer to the object at the back of the tree (the highest horizontal & vertical indices)

Definition at line 508 of file Tree.hpp.

◆ root

template<typename T >
std::unique_ptr<Child> Kale::Tree< T >::root

The root child of the tree, all other children stem from this one

Definition at line 529 of file Tree.hpp.


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