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


C++ destroy_tree函数代码示例

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


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

示例1: destroy_tree

void destroy_tree(struct tree_node *node,
		  tree_fn fnptr)
{
	if (node) {
		struct tree_node *left = node->left, *right = node->right;
		if (fnptr) {
			fnptr(node->data);
		}
		free(node);
		destroy_tree(left,fnptr);
		destroy_tree(right,fnptr);
	}
}
开发者ID:furquans,项目名称:generic,代码行数:13,代码来源:tree.c

示例2: destroy_tree

/* Deallocate all of the memory used by a BusinessNode BST, without memory
 * leaks.
 */
void destroy_tree(BusinessNode * root)
{
    if(root == NULL)
    {
        return;
    }
    destroy_tree(root->left);
    destroy_tree(root->right);
    free(root->name);
    free(root->stars);
    free(root->address);
    free(root);
}
开发者ID:arnavmittal,项目名称:ECE264,代码行数:16,代码来源:answer09.c

示例3: destroy_tree

void destroy_tree(BusinessNode * node)
{
    if(node == NULL)
	return;

    free(node -> name);
    free(node -> stars);
    free(node -> address);

    destroy_tree(node -> left);
    destroy_tree(node -> right);

    free(node);
}
开发者ID:yadav8,项目名称:ECE-264,代码行数:14,代码来源:answer09.c

示例4: destroy_tree

void destroy_tree(Node * root)
{//recursively frees all memory associated with the binary tree
	if (root == NULL)
	{
		return;
	}

	destroy_tree(root -> left);
	destroy_tree(root -> right);

	free(root);

	return;
}
开发者ID:DanJSuciu,项目名称:ECE368-Project2,代码行数:14,代码来源:unhuff.c

示例5: destroy_tree

void destroy_tree(binary_tree_s* psNode)
{
	binary_tree_s** ppsCur;

	ppsCur = &psNode;

	if (*ppsCur != NULL)
	{
		destroy_tree((*ppsCur)->m_psLeftNode);	
		destroy_tree((*ppsCur)->m_psRightNode);	
		free((*ppsCur));
		ppsCur = NULL;
	}
}
开发者ID:suonikeyinsuxiao,项目名称:trunk,代码行数:14,代码来源:binarytree.c

示例6: destroy_tree

void ADT::destroy_tree(Node *&leaf)
{
    if (leaf != NULL)
    {
        destroy_tree(leaf->left);
        destroy_tree(leaf->right);
        
        if (leaf->p != NULL)
        {
            delete leaf->p;
        }
        
        delete leaf;
        leaf = NULL;
    }
}
开发者ID:orxshi,项目名称:codeBaku2,代码行数:16,代码来源:ADT.cpp

示例7: main

int	main(void)
{
	char	*key;
	char	*value;
	char	*tmp;
	int		read;
	t_node	*root;

	read = 1;
	root = 0;
	while (read)
	{
		get_next_line(0, &key);
		read = get_next_line(0, &value);
		if (!ft_strcmp(key, ""))
			read = 0;
		else
			add_node(&root, key, value);
	}
	if (*value)
	{
		search_key(root, value);
		while (get_next_line(0, &tmp) > 0)
			search_key(root, tmp);
	}
	destroy_tree(&root);
	return (0);
}
开发者ID:ftibi,项目名称:hotrace,代码行数:28,代码来源:main.c

示例8: main

int main(int argc, char *argv[])
{
	struct rooted_tree *tree;	
	struct parameters params;
	static struct rooted_tree * (*process_tree)(struct rooted_tree *, set_t *);
	
	params = get_params(argc, argv);

	switch (params.mode) {
	case PRUNE_DIRECT:
		process_tree = process_tree_direct;
		break;
	case PRUNE_REVERSE:
		process_tree = process_tree_reverse;
		break;
	default:
		assert (0);
	}

	while (NULL != (tree = parse_tree())) {
		tree = process_tree(tree, params.prune_labels);
		dump_newick(tree->root);
		destroy_all_rnodes(NULL);
		destroy_tree(tree);
	}

	destroy_set(params.prune_labels);

	return 0;
}
开发者ID:Linhua-Sun,项目名称:newick_utils,代码行数:30,代码来源:prune.c

示例9: process_tree_reverse

static struct rooted_tree * process_tree_reverse(
		struct rooted_tree *tree, set_t *prune_labels)
{
	struct list_elem *el = tree->nodes_in_order->head;
	struct rnode *current;
	char *label;

	for (; NULL != el; el = el->next) {
		current = el->data;
		if (is_root(current)) break;
		label = current->label;
		/* mark this node (to keep it) if its label is on the CL */
		if (set_has_element(prune_labels, label)) {
			current->seen = true;
			struct prune_data *pdata =
				malloc(sizeof(struct prune_data));
			if (NULL == pdata) {perror(NULL); exit(EXIT_FAILURE); }
			pdata->kept_descendant = true;
			current->data = pdata;
		}
		/* and propagate 'seen' to parent (kept_descendant is
		 * propagated to children (not parents), see
		 * prune_predicate_keep_clade() */
		if (current->seen) {
			current->parent->seen = true;	/* inherit mark */
		}
	}

	struct rooted_tree *pruned = clone_tree_cond(tree,
			prune_predicate_keep_clade, prune_labels);	
	destroy_tree(tree);
	return pruned;
}
开发者ID:Linhua-Sun,项目名称:newick_utils,代码行数:33,代码来源:prune.c

示例10: main

int main(int argc, char **argv)
{
    if(argc < 2)
    {
        printf("Usage: %s forwarding_table_file\n\n", argv[0]);
        exit(0);
    }

    FILE *fp = fopen(argv[1], "r");
    if(fp == NULL)
    {
        printf("Unable to open '%s'\n\n", argv[1]);
        exit(-1);
    }

    /* load the list file to a binary tree data structure */

    node * tree = loadToTree(fp, argv);

    /* ORTC - step 1: discard interior next-hops */

    clear_interior_next_hops(tree);

    /* ORTC - step 2: calculate most frequent next-hops by traversing bottom up */

    percolate_tree(tree);

    /* ORTC - step 3: */

    clean_redundancy(tree, NULL);


    /* print to file */

    char destination[128];
    sprintf(destination, "%s.compressed", argv[1]);
    FILE * destination_file = fopen(destination, "w");
    if(fp == NULL)
    {
        printf("Unable to open '%s'\n\n", argv[1]);
        exit(-1);
    }

    printToFile(tree, destination_file);

#ifdef DEBUG
    printf("final tree (pre-order traversal): ");
    print_tree(tree);
    puts("\n");
#endif

    destroy_tree(tree);
    LSTdestroy(queue, destroyItem);
    fclose(fp);
    fclose(destination_file);

    puts("done.\n");

    exit(0);
}
开发者ID:goncalor,项目名称:ADRC,代码行数:60,代码来源:ORTC.c

示例11: c_test_ins_tree_height

void c_test_ins_tree_height(void) {
  int sizeOfElement = sizeof(struct complexThing);
  Tree tree = new_tree(sizeOfElement, navigateComplex, copyComplex, destroyComplex, NULL);
  CU_ASSERT_TRUE(get_tree_height(tree) == 0);

  Complex *c = malloc(sizeof(struct complexThing));
  c->int_regular = 10;
  c->int_pointer = malloc(sizeof(int));
  *c->int_pointer = 15;

  tree_insert(&tree, c, NULL);

  CU_ASSERT_TRUE(get_tree_height(tree) == 1);

  if (tree != NULL) {
    destroy_tree(&tree); 
  }

  if (c != NULL) {
    if (c->int_pointer != NULL) {
      free(c->int_pointer);
    }

    free(c);
  }
 
}
开发者ID:Tw1stedL0gic,项目名称:IOOPM-jojoca,代码行数:27,代码来源:treeTest.c

示例12: destroy_tree

void destroy_tree(node *root)
{
	node *n, *p;
	uint32_t i;

	for (n = root->children; n != NULL; n = p) {
		p = n->next;

		destroy_tree(n);
	}
	
	for (i = 0; i < root->n_attrs; ++i) {
		lwc_string_unref(root->attrs[i].name);
		lwc_string_unref(root->attrs[i].value);
	}
	free(root->attrs);

	if (root->classes != NULL) {
		for (i = 0; i < root->n_classes; ++i) {
			lwc_string_unref(root->classes[i]);
		}
		free(root->classes);
	}

	if (root->libcss_node_data != NULL) {
		css_libcss_node_data_handler(&select_handler, CSS_NODE_DELETED,
				NULL, root, NULL, root->libcss_node_data);
	}

	lwc_string_unref(root->name);
	free(root);
}
开发者ID:LucidFusionLabs,项目名称:libcss,代码行数:32,代码来源:select-common.c

示例13: main

int main(int argc, char *argv[])
{
	struct rooted_tree *tree;	
	struct hash *rename_map;
	struct parameters params;
	
	params = get_params(argc, argv);

	rename_map = read_map(params.map_filename);

	while (NULL != (tree = parse_tree())) {
		process_tree(tree, rename_map, params);
		destroy_tree(tree, DONT_FREE_NODE_DATA);
	}

	struct llist *keys = hash_keys(rename_map);
	if (NULL == keys) { perror(NULL); exit(EXIT_FAILURE); }
	struct list_elem *e;
	for (e = keys->head; NULL != e; e = e->next) {
		char *key = (char *) e->data;
		char *val = hash_get(rename_map, key);
		free(val);
	}
	destroy_llist(keys);
	destroy_hash(rename_map);

	return 0;
}
开发者ID:gatoravi,项目名称:MFAST,代码行数:28,代码来源:rename.c

示例14: destroy_tree

void IntervalMap::freeIntervalMap() {
	/*for (int i = 0; i < numberOfIntervalls; i++) {
	 delete map[i];
	 }
	 delete[] this->map;*/
	destroy_tree(map);
}
开发者ID:Basti2702,项目名称:MA,代码行数:7,代码来源:IntervalMap.cpp

示例15: find_three_layer

void find_three_layer()
{
	int i=0;
	int j=0;
	int k=0;
	FILE *f_results;
	f_results = fopen(nondom_file, "a");
	for(i=1 ; i<=number_of_features ; i++)
	{
		current_round = i;
		printf("\n\n###################### ROUND %d ########################\n",i);
		find_a_layer();
		final_pareto_front();
		k=0;
		for(j=0 ; j<population_size ; j++)
		{
			if(dominated[j]==False)
			{
				pop[i][k].root = population[j].root;
				pop[i][k].fitness = population[j].fitness;
				pop[i][k].cost = population[j].cost;
				k++;
			}
			else
				destroy_tree(population[j].root);
		}
		pop_count[current_round]=k;
		fprintf(f_results,"\nthe number of solutions = %d\n",pop_count[current_round]);
	}
	fclose(f_results);
}
开发者ID:Afsoon-yz,项目名称:hierarchical-GP,代码行数:31,代码来源:2h05t100r.c


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