当前位置: 首页>>代码示例>>C++>>正文


C++ destroyTree函数代码示例

本文整理汇总了C++中destroyTree函数的典型用法代码示例。如果您正苦于以下问题:C++ destroyTree函数的具体用法?C++ destroyTree怎么用?C++ destroyTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了destroyTree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: destroyTree

void exprTree::destroyTree(Node *leaf) {
	if (leaf != nullptr) {
		destroyTree(leaf->left);
		destroyTree(leaf->right);
		delete leaf;
	}
}
开发者ID:LaurenceGA,项目名称:programmingProjects,代码行数:7,代码来源:extree.cpp

示例2: so

/*prints all the files associated with any word*/
int so(char *str, hashTable *ht) {
  char *word;
  FileNode *fptr; /* Iterates through filenames  */

  if (strcmp(strtok(str, " "), "so") != 0) {
    printf("I did not get 'so' inside sa function!!\n");
    return 1;
  }

  /* goes through each word in input */
  while ((word = strtok(NULL, " "))) {
    for (ptr = getFiles(word, root); ptr != NULL;
        ptr = ptr->next) {
      insert_to_list(t, ptr->filename);
    }
  }

  /* Means we got no matches */
  if (t->files == NULL) {
    printf("No matches found.\n");
    destroyTree(t);
    return 1;
  }

  /* prints all the filenames */
  for (ptr = t->files; ptr->next != NULL; ptr = ptr->next)
    printf("%s, ", ptr->filename);
  if (ptr)
    printf("%s\n", ptr->filename);

  destroyTree(t);
  return 0;
}
开发者ID:darthvader1118,项目名称:iLab-stuff,代码行数:34,代码来源:saso.c

示例3: destroyTree

void Node::destroyTree(Node *a) {
	if (a != NULL)
	{
		destroyTree(a->left);
		destroyTree(a->right);
		delete a;
	}
};
开发者ID:Themiak,项目名称:SDiZO,代码行数:8,代码来源:L4.cpp

示例4: destroyTree

void destroyTree(node *in){

  if(in != 0){
    destroyTree(in->left);
    destroyTree(in->right);
    free(in);
  }
}
开发者ID:scarter93,项目名称:Data-Structures,代码行数:8,代码来源:binarySearchTree.c

示例5: destroyTree

void destroyTree(struct tree* victim){
    if(victim->son1)
       destroyTree(victim->son1);
    if(victim->son2)
       destroyTree(victim->son2);
    free(victim);
    victim = 0; 
}
开发者ID:awarematics,项目名称:SECONDO,代码行数:8,代码来源:Tree.c

示例6: destroyTree

 void destroyTree(NodePtr leaf) {
   if(leaf != nullptr) {
     destroyTree(leaf->left);
     destroyTree(leaf->right);
     delete leaf;
     --numberOfNodes;
   }
 } 
开发者ID:gregvw,项目名称:data-structures,代码行数:8,代码来源:bst.hpp

示例7: bipartGraphDestroy

void bipartGraphDestroy(bpGraph_t* pGraph)
{
	/* TODO: Implement me! */
	destroyTree(pGraph->vpVertsP1);
	destroyTree(pGraph->vpVertsP2);
	safeFree(pGraph, sizeof(bpGraph_t));
	pGraph = NULL;
} /* end of bipartGraphDestroy() */
开发者ID:j1nhu,项目名称:Bipartite-Graph,代码行数:8,代码来源:bpGraphAdjList_BL.c

示例8: destroyTree

//--------------------------------------------------------------------------
// void destroyTree(BSTNode* subTreePtr);
// Taken from Carrano et al.: method used to destruct a BST
// Preconditions: BST exists
// Postconditions: BST is destructed
// Return value: None
// Functions called: Recursive call to itself
void BST::destroyTree(BSTNode* subTreePtr) {
   if (subTreePtr != nullptr)
   {
      destroyTree(subTreePtr->left);
      destroyTree(subTreePtr->right);
      delete subTreePtr;
   }
} 
开发者ID:kestemm,项目名称:work_examples,代码行数:15,代码来源:BST.cpp

示例9: destroyTree

void destroyTree(HuffNode * tree)
/*This function deallocates the memory allocated by the Huffman tree.*/ 
{
  if(tree == NULL){return;}//base case:reach the leaf of the tree, return to free the leaf
  destroyTree(tree -> left);//check all the left children
  destroyTree(tree -> right);//check all the right children
  free(tree);//free the memory of the tree
}
开发者ID:kibazhang,项目名称:C_Programming_Related,代码行数:8,代码来源:helper.c

示例10: destroyTree

//Deallocates memory for the given root and all its subtrees
//O(h)
void destroyTree(struct tree *root){

    //Since this is a tree, we can use post order recursion to recusrivley delete all the nodes in the left and right subtree then the root
	if(root!=NULL){
		destroyTree(root->left);
		destroyTree(root->right);
		free(root);
	}
}
开发者ID:maxabrams,项目名称:Huffman-Coding,代码行数:11,代码来源:tree.c

示例11: destroyTree

// Private destroyTree function.  It will delete all the nodes of the tree
void BinaryTree::destroyTree(TreeNode *leaf)
{
	if(leaf!=NULL)
	{
		destroyTree(leaf->left);
		destroyTree(leaf->right);
		delete leaf;
	}
}
开发者ID:et2372584,项目名称:EdgarTrujilloSanchez_CSC17C_48942,代码行数:10,代码来源:BinaryTree.cpp

示例12: bipartGraphDestroy

void bipartGraphDestroy(bpGraph_t* pGraph)
{
    /* Destroy each partite tree */
    destroyTree(*pGraph->vertices1);
    destroyTree(*pGraph->vertices2);

    /* Free the graph struct */
    safeFree(pGraph, sizeof(pGraph));
} /* end of bipartGraphDestroy() */
开发者ID:S4KH,项目名称:algo-analyse,代码行数:9,代码来源:bpGraphAdjList_BL.c

示例13: destroyTree

void LinkedBinaryTree<T>::destroyTree(Node* p) {
  
  if (p != NULL) {
    destroyTree(p->left);
    destroyTree(p->right);
    delete p;
  }
  
}
开发者ID:ingamelkerte,项目名称:GoodrichTamassiaCpp,代码行数:9,代码来源:linkedTree.hpp

示例14: destroyTree

void BinaryNodeTree<ItemType>::destroyTree(BinaryNode<ItemType>* subTreePtr)
{
   if (subTreePtr != nullptr)
   {
      destroyTree(subTreePtr->getLeftChildPtr());
      destroyTree(subTreePtr->getRightChildPtr());
      delete subTreePtr;
   }  // end if
}  // end destroyTree
开发者ID:kylienic,项目名称:CTP-250,代码行数:9,代码来源:BinaryNodeTree.cpp

示例15: destroyTree

void BST::destroyTree(TreeNode *& treePtr)
{
   // postorder traversal
   if (treePtr != NULL)
   {  destroyTree(treePtr->leftChildPtr);
      destroyTree(treePtr->rightChildPtr);
      delete treePtr;
      treePtr = NULL;
   }  // end if
}  // end destroyTree
开发者ID:elisemmc,项目名称:EECS268,代码行数:10,代码来源:BST.cpp


注:本文中的destroyTree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。