本文整理汇总了C++中freeTree函数的典型用法代码示例。如果您正苦于以下问题:C++ freeTree函数的具体用法?C++ freeTree怎么用?C++ freeTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了freeTree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: heightTest
void heightTest(void){
treeADT treeOrd,treeRev,treeRan;
int i,TEST_SIZE,NUM_OF_TESTS;
double sum=0;
system("cls");
printf("Tree Height Tester\n\n");
printf("Enter tree size: ");
TEST_SIZE=GetInteger();
if(TEST_SIZE<=0)
Error("I refuse!");
printf("Enter number of tests to run: ");
NUM_OF_TESTS=GetInteger();
printf("\n");
if(NUM_OF_TESTS<=0)
Error("I refuse!");
printf("Random input || Tree size: %d || Number of tests: %d\n",TEST_SIZE,NUM_OF_TESTS);
for(i=0;i<NUM_OF_TESTS;i++){
treeRan=buildTestTreeRandom(TEST_SIZE);
sum+=treeHeight(treeRan);
freeTree(treeRan);
}
sum/=NUM_OF_TESTS;
printf("Average height: %.2f\n\n",sum);
sum=0;
if(TEST_SIZE>20000){
printf("Warning! This function uses recursion to measure height\n");
printf("Big inputs makes it sad :-(\n");
printf("To avoid crash, the height is just printed out.\n\n");
printf("Increasing input || Tree size: %d\n",TEST_SIZE);
printf("Average height: %d\n\n",TEST_SIZE);
printf("Decreasing input || Tree size: %d\n",TEST_SIZE);
printf("Average height: %d\n\n",TEST_SIZE);
}
else{
printf("Increasing input || Tree size: %d || Number of tests: %d\n",TEST_SIZE,NUM_OF_TESTS);
for(i=0;i<NUM_OF_TESTS;i++){
treeOrd=buildTestTreeOrdered(TEST_SIZE);
sum+=treeHeight(treeOrd);
freeTree(treeOrd);
}
sum/=NUM_OF_TESTS;
printf("Average height: %.2f\n\n",sum);
sum=0;
printf("Decreasing input || Tree size: %d || Number of tests: %d\n",TEST_SIZE,NUM_OF_TESTS);
for(i=0;i<NUM_OF_TESTS;i++){
treeRev=buildTestTreeReversed(TEST_SIZE);
sum+=treeHeight(treeRev);
freeTree(treeRev);
}
sum/=NUM_OF_TESTS;
printf("Average height: %.2f\n\n",sum);
sum=0;
}
printf("\nPress enter to return.");
getchar();
}
开发者ID:diffus,项目名称:Red-Black-Trees,代码行数:60,代码来源:main.c
示例2: freeTree
//Frees memory
void freeTree(node *ptr){
if (ptr != NULL) {
freeTree(ptr->left);
freeTree(ptr->right);
free(ptr);
}
}
开发者ID:phoofboy,项目名称:Data-Structures,代码行数:8,代码来源:Assign6.c
示例3: testCase
bool testCase(int *num, int numsSize) {
struct TreeNode *root = buildTree(num, numsSize);
showTree(root);
// How to use serialize and deserialize
char *data = serialize(root);
struct TreeNode *node = deserialize(data);
printf("serialize to [%s]\n", data);
bool r = eqTree(root, node);
printf("deserialize to\n");
if (!r) {
showTree(node);
} else {
printf("same\n");
}
printf("%s\n", expect(r));
freeTree(root);
freeTree(node);
if (data) {
free(data);
}
return r;
}
开发者ID:liuyang1,项目名称:test,代码行数:25,代码来源:serializeTree.297.c
示例4: freeTree
void freeTree(ANode * tree)
{
Node<Outlook> * o = dynamic_cast<Node<Outlook> *>(tree);
Node<Temperature> * t = dynamic_cast<Node<Temperature> *>(tree);
Node<Humidity> * h = dynamic_cast<Node<Humidity> *>(tree);
Node<Wind> * w = dynamic_cast<Node<Wind> *>(tree);
if (o != NULL)
{
std::map<Outlook, ANode *>::iterator it = o->getChilds().begin();
for (; it != o->getChilds().end(); ++it)
freeTree(it->second);
}
else if (t != NULL)
{
std::map<Temperature, ANode *>::iterator it = t->getChilds().begin();
for (; it != t->getChilds().end(); ++it)
freeTree(it->second);
}
else if (h != NULL)
{
std::map<Humidity, ANode *>::iterator it = h->getChilds().begin();
for (; it != h->getChilds().end(); ++it)
freeTree(it->second);
}
else if (w != NULL)
{
std::map<Wind, ANode *>::iterator it = w->getChilds().begin();
for (; it != w->getChilds().end(); ++it)
freeTree(it->second);
}
delete tree;
}
开发者ID:Surogate,项目名称:ai-playground,代码行数:33,代码来源:main.cpp
示例5: freeTree
void freeTree( Tree * t ) {
if( !t ) return;
freeTree( t->left );
freeTree( t->right );
free( t );
}
开发者ID:joseph8th,项目名称:unm-cs,代码行数:7,代码来源:week11.c
示例6: freeTree
/* Free tree */
void freeTree(queue *root){
if(root == NULL)
return;
freeTree(root->left);
freeTree(root->right);
free(root);
}
开发者ID:aachiritoaei,项目名称:huffman-archiver,代码行数:8,代码来源:huffman.c
示例7: freeTree
void freeTree(Sprig* thisSprig) {
if (thisSprig == NULL) return;
//free childSprigs first
freeTree(thisSprig->leftSprig);
int i = numLeaves(thisSprig);
Leaf* curr = thisSprig->firstLeaf;
for (; i>0; i--) {
freeTree(curr->childSprig);
curr = curr->nextLeaf;
}
//then free leaves in own scope
curr = thisSprig->firstLeaf;
Leaf* next = curr->nextLeaf;
for(i=numLeaves(thisSprig); i>0; i--) {
free(curr);
curr = next;
if (curr != NULL) next = curr->nextLeaf;
}
//then free self
free(thisSprig);
return;
}
开发者ID:evanrichter,项目名称:CS359,代码行数:26,代码来源:btree.c
示例8: freeTree
void freeTree(HuffmanNode* node) {
if(node != nullptr){
freeTree(node->zero);
freeTree(node->one);
delete node;
}
}
开发者ID:JohanssonDaniel,项目名称:Huffman,代码行数:7,代码来源:encoding.cpp
示例9: freeTree
// Frees a condition and all of it's sub conditions
void freeTree(Condition* c)
{
if (c->lhs) freeTree(c->lhs);
if (c->rhs) freeTree(c->rhs);
free(c);
}
开发者ID:HerbFargus,项目名称:FCE3D,代码行数:8,代码来源:conddebug.cpp
示例10: freeTree
void freeTree(avlNode **node){
if(*node){
freeTree(&(*node)->left);
freeTree(&(*node)->right);
free(*node);
}
}
开发者ID:diogomg,项目名称:tree,代码行数:7,代码来源:avl-tree.c
示例11: testIsEquiv
void testIsEquiv()
{
printf("###########################\n");
printf("Test 5. is_equiv: ");
BTree *t1 = testTree1();
BTree *t2 = testTree2();
if (isEquivBTree(t1, t2)){
printf("NOK - B-stromy nejsou ekvivalentni, nemaji shodnou aritu\n");
}else{
freeTree(t1); freeTree(t2);
t1 = testTree2();
t2 = testTree4();
if (isEquivBTree(t1, t2)){
printf("NOK - B-stromy nejsou ekvivalentni, nemaji shodne hodnoty\n");
}else{
freeTree(t1);
t1 = testTree2();
if (isEquivBTree(t1, t1)){
printf("OK\n");
}else{
printf("NOK - B-stromy jsou ekvivalentni\n");
}
}
}
freeTree(t1); freeTree(t2);
}
开发者ID:hudecek,项目名称:algorithmsHW,代码行数:26,代码来源:main.c
示例12: freeTree
void QMapDataBase::freeTree(QMapNodeBase *root, int alignment)
{
if (root->left)
freeTree(root->left, alignment);
if (root->right)
freeTree(root->right, alignment);
qMapDeallocate(root, alignment);
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:8,代码来源:qmap.cpp
示例13: freeTree
void freeTree(TreeNode *T, Tree * Tr) {
if (T->left != NULL)
freeTree(T->left,Tr);
if (T->right != NULL)
freeTree(T->right,Tr);
Tr->destroyValue(T->value);
free(T);
}
开发者ID:iistyler,项目名称:Data-Structures,代码行数:8,代码来源:TreeImplementation.c
示例14: freeTree
void freeTree(Ast* temp) {
if ( temp ) {
Ast* left = temp->getLeft();
Ast* right = temp->getRight();
delete temp;
freeTree(left);
freeTree(right);
}
}
开发者ID:jhester,项目名称:piethon-interpreter,代码行数:9,代码来源:ast.cpp
示例15: freeTree
void freeTree(astNode *root) {
if (root != NULL) {
if (root->next != NULL) freeTree(root->next);
if (root->op.left != NULL) freeTree(root->op.left);
if (root->op.right != NULL) freeTree(root->op.right);
if (root->str != NULL) free(root->str);
free(root);
}
}
开发者ID:LaurenceGA,项目名称:arm,代码行数:9,代码来源:ast.c
示例16: freeTree
void _redblacktree::freeTree( tree *root ) {
if( !root ) {
freeTree(root->left);
freeTree(root->right);
}
delete root;
}
开发者ID:powernano,项目名称:Alloc,代码行数:9,代码来源:_redblacktree.cpp
示例17: freeTree
void freeTree(t_node *root)
{
if (root)
{
freeTree(root->left);
freeTree(root->right);
free(root);
}
}
开发者ID:eriq-augustine,项目名称:evil,代码行数:9,代码来源:bert.c
示例18: freeTree
void freeTree(struct treeNode *root)
{
if(root != NULL)
{
freeTree(root->left);
freeTree(root->right);
free(root);
}
}
开发者ID:mchenchen,项目名称:Course-Work,代码行数:9,代码来源:treeTester.c
示例19: freeTree
void freeTree(Tree *root)
{
if (root == NULL)
return;
freeTree(root->left);
freeTree(root->right);
if (root->left == NULL && root->right == NULL)
free(root);
}
开发者ID:gmyofustc,项目名称:CS-notes,代码行数:9,代码来源:sort.c
示例20: freeTree
static void freeTree(ttree_express *r)
{
if (!r)
return;
freeTree(r->left);
freeTree(r->right);
free(r);
}
开发者ID:frcoelho,项目名称:pesti,代码行数:9,代码来源:control-flow-graph.c
注:本文中的freeTree函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论