you could declare some structs and define a set functions that process the structs like so:
struct metaData; // forward declaration
struct treeNode
{
metaData* myData;
treeNode* leftChild;
treeNode* RightChild;
}
struct tree
{
treeNode* rootNode;
}
// function example
tree* createTree() // creates an empty tree Container
treeNode* createNode(metaData& Input) //create a new tree node and intializes with your meta data
int addNode(tree* myTree, treeNode* newNode) //adds news nodes to tree)
// any other functions needed
you could like wise declare as classes with a set methods to operate on the object:
class treeNode
{
private:
metaData* myData;
treeNode* leftChild;
treeNode* rightChild;
public:
treeNode(); // constructor set initial conditions of object
setData(); //sets MetaData
setLeft(); // attaches a left child
setRight(); // attaches a right child
// any other methods that you need
}
class Tree
{
private:
treeNode* Root;
public:
Tree(); constructor set initial of tree
setRoot();
add(); // add a node to tree
delete(); // deletes a node from tree
// any other methods you want
}
or you could use existing STL containers like stacks, maps, lists, etc...
|