Next: Output and Deletion Up: Creating a New Previous: Creating the New

Adding Children Nodes

You may add nodes to an existing tree by calling F_addChild(). F_addChild() It takes two arguments. The first is a pointer to the parent, which must already exist on the tree. The second is a pointer to the child. The routine creates the new child node, links it into the tree as a child of the parent node, and makes the second pointer point at the newly created child. Just as in F_createTree(), FARFALLA uses the type of the second argument to determine what type of new node to create.

The following code creates the tree shown in Figure .


eventNode *evPtr;
F_createTree(evPtr);
evPtr->run = 12;

erpNode *erpPtr;
for (int i = 0; i < 3; i++)     // Loop through block 3 times
{
  F_addChild(evPtr,erpPtr);     // Each time through loop an erp node is
  erpPtr->boxnum = i+1;         // created and filled
}

wireTrackNode *wtrkPtr;
F_addChild(evPtr,wtrkPtr);      // Finally a wire track node is created
wtrkPtr->slope = 1.3;           // and filled

(Note the use of a single pointer, erpPtr, to access three different erpNodes, one for each pass through the for loop.)

Of course, F_addChild() may be called any time, not just in the routine that originally created the tree. For example, if you are doing some experimental reconstructions, you may wish to read in a FARFALLA tree from disk, use the data in it to do some computations, and then add new nodes to the tree with the results of your computations. Later subroutines may use the newly-created nodes in analysis.


walter@
Wed Aug 10 11:53:26 PDT 1994