Basic tree node structure.
More...
#include <TreeNode.h>
|
virtual bool | isEqual (const TreeNode &node) const |
| Returns true if the nodes are equal; otherwise, returns false. More...
|
|
virtual bool | doAccept (TreeVisitor *visitor)=0 |
| Private function for use with the visitor pattern, this needs to be implemented to make the correct double dispatch call to the dynamic type of this class. More...
|
|
void | setNumChildren (size_t numChildren) |
| Sets the number of children of this node. More...
|
|
void | addChild (const std::shared_ptr< TreeNode > &node) |
| Add a child to this node. More...
|
|
void | addChild (const std::shared_ptr< TreeNode > &&node) |
| Add a child to this node. More...
|
|
void | setChild (size_t index, const std::shared_ptr< TreeNode > &node) |
| Set a specific child of this node. More...
|
|
Basic tree node structure.
The nodes build up the structure of a Tree.
- See also
- Tree TreeData
§ accept()
void SurgSim::DataStructures::TreeNode::accept |
( |
TreeVisitor * |
visitor | ) |
|
Public entry point for visitor, currently this performs pre-order traversal of the tree.
- Parameters
-
visitor | The visitor that wants to traverse the tree |
§ addChild() [1/2]
void SurgSim::DataStructures::TreeNode::addChild |
( |
const std::shared_ptr< TreeNode > & |
node | ) |
|
|
protected |
Add a child to this node.
- Parameters
-
§ addChild() [2/2]
void SurgSim::DataStructures::TreeNode::addChild |
( |
const std::shared_ptr< TreeNode > && |
node | ) |
|
|
protected |
Add a child to this node.
- Parameters
-
§ doAccept()
virtual bool SurgSim::DataStructures::TreeNode::doAccept |
( |
TreeVisitor * |
visitor | ) |
|
|
protectedpure virtual |
Private function for use with the visitor pattern, this needs to be implemented to make the correct double dispatch call to the dynamic type of this class.
- Parameters
-
visitor | The visitor that is trying to traverse the tree. |
- Returns
- true to indicate proceeding with the visitor, false indicates to abort the traversal.
Implemented in SurgSim::DataStructures::AabbTreeNode.
§ getChild()
std::shared_ptr< TreeNode > & SurgSim::DataStructures::TreeNode::getChild |
( |
size_t |
index | ) |
|
Returns the specified child of this node.
- Parameters
-
- Returns
- Child at the specified index
§ getData()
const std::shared_ptr< TreeData > & SurgSim::DataStructures::TreeNode::getData |
( |
| ) |
const |
- Returns
- The data of this node.
§ getNumChildren()
size_t SurgSim::DataStructures::TreeNode::getNumChildren |
( |
| ) |
const |
- Returns
- The number of children of this node.
§ isEqual()
bool SurgSim::DataStructures::TreeNode::isEqual |
( |
const TreeNode & |
node | ) |
const |
|
protectedvirtual |
Returns true if the nodes are equal; otherwise, returns false.
Recurses on children. Override this method in derived classes to implement different comparisons.
- Parameters
-
node | The node for comparison. |
- Returns
- true if this node is equal to the node in the parameter.
§ operator!=()
bool SurgSim::DataStructures::TreeNode::operator!= |
( |
const TreeNode & |
node | ) |
const |
Returns true if the nodes are not equal; otherwise, returns false.
If the nodes are not of the same type, returns false; otherwise, compares with the implementation of isEqual(const TreeNode&).
- Parameters
-
node | The node for comparison. |
- Returns
- true if this node and the parameter are not equal
§ operator==()
bool SurgSim::DataStructures::TreeNode::operator== |
( |
const TreeNode & |
node | ) |
const |
Returns true if the nodes are equal; otherwise, returns false.
If the nodes are not of the same type, returns false; otherwise, compares with the implementation of isEqual(const TreeNode&).
- Parameters
-
node | The node for comparison. |
- Returns
- true is this node and the one from the parameter are equal.
§ setChild()
void SurgSim::DataStructures::TreeNode::setChild |
( |
size_t |
index, |
|
|
const std::shared_ptr< TreeNode > & |
node |
|
) |
| |
|
protected |
Set a specific child of this node.
- Parameters
-
index | Index of the child |
node | Node to become a child |
§ setData()
void SurgSim::DataStructures::TreeNode::setData |
( |
std::shared_ptr< TreeData > |
data | ) |
|
Sets the data of this node.
- Parameters
-
data | The data for this node. |
§ setNumChildren()
void SurgSim::DataStructures::TreeNode::setNumChildren |
( |
size_t |
numChildren | ) |
|
|
protected |
Sets the number of children of this node.
Any added children will be null.
- Parameters
-
numChildren | The new number of children. |
The documentation for this class was generated from the following files:
- SurgSim/DataStructures/TreeNode.h
- SurgSim/DataStructures/TreeNode.cpp