SpatiumLib
|
#include <TreeNode.h>
Public Member Functions | |
TreeNode (std::weak_ptr< TreeNode< G >> parent=std::weak_ptr< TreeNode< G >>(), size_t estimatedChildCount=0) | |
Constructor. More... | |
TreeNode (const G &object, std::weak_ptr< TreeNode< G >> parent=std::weak_ptr< TreeNode< G >>(), size_t estimatedChildCount=0) | |
Constructor. More... | |
bool | hasChildren () |
size_t | childCount () const |
Get child count. More... | |
std::shared_ptr< TreeNode< G > > | child (size_t index) const |
Get a child. More... | |
std::shared_ptr< TreeNode< G > > | addChild (const std::shared_ptr< TreeNode< G >> &parentSharedPtr, const G &object) |
Add child node. More... | |
G & | object () |
Set the object. More... | |
void | setObject (const G &object) |
Get the object. More... | |
Protected Attributes | |
std::weak_ptr< TreeNode< G > > | m_parent |
std::vector< std::shared_ptr< TreeNode< G > > > | m_children |
G | m_object |
Node in a Tree.
TreeNode is a node in a Tree. Each node can have any number of children. A TreeNode is a container for a single object. The type of this object is passed as template argument.
|
inline |
Constructor.
[in] | parent | Parent node |
[in] | estimatedChildCount | Estimated child count. Will allocate memory for the child references in advance to prevent later reallocation. |
|
inline |
Constructor.
[in] | object | Object for node |
[in] | parent | Parent node |
[in] | estimatedChildCount | Estimated child count. Will allocate memory for the child references in advance to prevent later reallocation. |
|
inline |
Add child node.
[in] | parentSharedPtr | Parent node (this object) as shared pointer. |
[in] | object | Object |
|
inline |
Get a child.
[in] | index | Child index |
|
inline |
Get child count.
|
inline |
|
inline |
Set the object.
|
inline |
Get the object.
|
protected |
|
protected |
|
protected |