IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
SimpleTreeNode Class Reference

The SimpleTreeNode is just what it says on the tin... a very simple node to form a tree structure. More...

Public Member Functions

 SimpleTreeNode (int _id, SimpleTreeNode *_parent)
 Constructs a node with an id and inserts it into a tree. More...
 
 ~SimpleTreeNode ()
 Recursively deletes the entire tree when called on the root. More...
 
SimpleTreeNodeGetParent ()
 
int GetId ()
 

Private Member Functions

void addChild (SimpleTreeNode *child)
 Adds a child to this node. Done automatically when a childnode is created. More...
 

Private Attributes

vector< SimpleTreeNode * > children
 Stores all children of this node.
 
SimpleTreeNodeparent = NULL
 Stores the parent of this node.
 
int id
 Stores the id of this node.
 

Detailed Description

The SimpleTreeNode is just what it says on the tin... a very simple node to form a tree structure.

It is used by the breadth-first algorithm to put its results in a nice tree structure where the shortest path can be traced back without effort. Note that this structures single purpose is to PRESERVE order and connection of elements among each other. It makes for a lousy search and sorting structure, and therefore has no functions to facilitate these things. Use a map if you need a search tree.

Constructor & Destructor Documentation

SimpleTreeNode::SimpleTreeNode ( int  _id,
SimpleTreeNode _parent 
)
inline

Constructs a node with an id and inserts it into a tree.

The node's id and position in the tree are fixed and can never change!

Parameters
_idThe id for the node. Must be unique in the entire tree
_parentThe parent node this node should be inserted after.
Note
If the node you are creating is a tree's root, pass NULL for _parent.
SimpleTreeNode::~SimpleTreeNode ( )
inline

Recursively deletes the entire tree when called on the root.

will trigger an assert if NOT called on the root!

Member Function Documentation

void SimpleTreeNode::addChild ( SimpleTreeNode child)
inlineprivate

Adds a child to this node. Done automatically when a childnode is created.

Parameters
childThe node to add as a child
int SimpleTreeNode::GetId ( )
inline
Returns
The id of this node
SimpleTreeNode* SimpleTreeNode::GetParent ( )
inline
Returns
The parent of this node

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