コード例 #1
0
ファイル: driver.cpp プロジェクト: Ssuarez0/CS3100-Projects
/*
Function Name: printVisit
Purpose: Visit function to be used
with PRINT for printing out remaining
suspects in a tree.
*/
void printVisit(TreeItemType& suspect)
{
  if(suspect.isSuspect){
    cout << suspect.getKey() << endl;
  }
  return;
}
コード例 #2
0
ファイル: BST.cpp プロジェクト: elisemmc/EECS268
void BST::insertItem(TreeNode *& treePtr,
                     const TreeItemType& newItem)
                     throw(TreeException)

{
   if (treePtr == NULL)
   {  // position of insertion found; insert after leaf

      // create a new node
      treePtr = new TreeNode(newItem, NULL, NULL);
   }
   // else search for the insertion position
   else if (newItem.getKey() < treePtr->item.getKey())
      // search the left subtree
      insertItem(treePtr->leftChildPtr, newItem);

   else if(newItem.getKey() > treePtr->item.getKey())
      // search the right subtree
      insertItem(treePtr->rightChildPtr, newItem);
   else
     throw TreeException("Attempted to insert duplicate key.");
}  // end insertItem
コード例 #3
0
ファイル: driver.cpp プロジェクト: Ssuarez0/CS3100-Projects
/*
Function Name: saveVisit
Purpose: Visit function to be used
with quit for saving each node.
*/
void saveVisit(TreeItemType& suspect, ofstream& stream)
{
  string a_string, keyName;
  keyName = suspect.getKey();
  upCase(keyName);
  int numberofAttr = suspect.attributes.getLength();
  //increment number of attributes for loop condition
  ++numberofAttr;
  stream << "Name:" << endl;
  stream << keyName << endl;
  stream << "Attributes:" << endl;
  for(int i = 1; i<numberofAttr; ++i){
    suspect.attributes.retrieve(i, a_string);
    upCase(a_string);
    stream << a_string << endl;
  }
  stream << "$" << endl;
  return;
}