您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stack_destroy函数代码示例

51自学网 2021-06-03 08:20:59
  C++
这篇教程C++ stack_destroy函数代码示例写得很实用,希望能帮到您。

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

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

示例1: xml_spack

/****************************************************************************** **函数名称: xml_spack **功    能: 根据XML树构建XML报文(注: XML无层次格式) **输入参数: **     xml: XML树 **     str: 用于存放XML报文 **输出参数: **返    回: 返回XML文件报文的长度 **实现描述:  **注意事项:  **作    者: # Qifeng.zou # 2013.03.01 # ******************************************************************************/extern int xml_spack(xml_tree_t *xml, char *str){    sprint_t sp;    Stack_t stack;    xml_node_t *child = xml->root->child;    if (NULL == child) {        return XML_OK;    }    sprint_init(&sp, str);        if (stack_init(&stack, XML_MAX_DEPTH)) {        log_error(xml->log, "Stack init failed!");        return XML_ERR_STACK;    }    while (NULL != child) {        if (xml_pack_tree(xml, child, &stack, &sp)) {            log_error(xml->log, "Sprint tree failed!");            stack_destroy(&stack);            return XML_ERR;        }        child = child->next;    }        stack_destroy(&stack);    return (sp.ptr - sp.str);}
开发者ID:object8421,项目名称:tanlz,代码行数:41,


示例2: board_destroy

/* Used to free the memory of a board and all associated cells */void board_destroy(Board *board){    free(board->cells);    free(board);    stack_destroy(board->stack_a);    stack_destroy(board->stack_b);}
开发者ID:ignaciohermosillacornejo,项目名称:Backtracking,代码行数:8,


示例3: xml_fprint

/****************************************************************************** **函数名称: xml_fprint **功    能: 根据XML树构建XML文件(注: XML有层次格式) **输入参数: **     xml: XML树 **     fp: 文件指针 **输出参数: **返    回: 0:成功 !0:失败 **实现描述:  **注意事项:  **作    者: # Qifeng.zou # 2013.03.26 # ******************************************************************************/int xml_fprint(xml_tree_t *xml, FILE *fp){    Stack_t stack;    xml_node_t *child = xml->root->child;    if (NULL == child) {        log_error(xml->log, "The tree is empty!");        return XML_ERR_EMPTY_TREE;    }        if (stack_init(&stack, XML_MAX_DEPTH)) {        log_error(xml->log, "Stack init failed!");        return XML_ERR_STACK;    }    while (NULL != child) {        if (xml_fprint_tree(xml, child, &stack, fp)) {            log_error(xml->log, "fPrint tree failed!");            stack_destroy(&stack);            return XML_ERR;        }        child = child->next;    }    stack_destroy(&stack);    return XML_OK;}
开发者ID:object8421,项目名称:tanlz,代码行数:39,


示例4: xml_node_len

/****************************************************************************** **函数名称: xml_node_len **功    能: 计算XML树打印成XML格式字串时的长度(注: 有层次结构) **输入参数: **     xml: XML树 **     node: XML节点 **输出参数: **返    回: XML格式字串长度 **实现描述:  **注意事项:  **作    者: # Qifeng.zou # 2013.06.10 # ******************************************************************************/int xml_node_len(xml_tree_t *xml, xml_node_t *node){    int len;    Stack_t stack;        if (NULL == node) {        log_error(xml->log, "The node is empty!");        return 0;    }        if (stack_init(&stack, XML_MAX_DEPTH)) {        log_error(xml->log, "Stack init failed!");        return -1;    }    len = _xml_node_len(xml, node, &stack);    if (len < 0) {        log_error(xml->log, "Get the len of node failed!");        stack_destroy(&stack);        return -1;    }    stack_destroy(&stack);    return len;}
开发者ID:object8421,项目名称:tanlz,代码行数:37,


示例5: _xml_pack_len

/****************************************************************************** **函数名称: _xml_pack_len **功    能: 计算XML树打印成XML报文字串时的长度(注: XML无层次结构) **输入参数: **     node: XML节点 **输出参数: NONE **返    回: 报文长度 **实现描述:  **注意事项:  **作    者: # Qifeng.zou # 2013.06.11 # ******************************************************************************/int _xml_pack_len(xml_tree_t *xml, xml_node_t *node){    int len, len2;    Stack_t stack;    xml_node_t *child;        if (NULL == node) {        log_error(xml->log, "The node is empty!");        return 0;    }        if (stack_init(&stack, XML_MAX_DEPTH)) {        log_error(xml->log, "Stack init failed!");        return -1;    }    len = 0;    switch(node->type)    {        case XML_NODE_CHILD: /* 处理孩子节点 */        {            len = xml_pack_node_len(xml, node, &stack);            if (len < 0) {                log_error(xml->log, "Get len of the node failed!");                stack_destroy(&stack);                return -1;            }            break;        }        case XML_NODE_ROOT:  /* 处理父亲节点 */        {            child = node->child;            while (NULL != child) {                len2 = xml_pack_node_len(xml, child, &stack);                if (len2 < 0) {                    log_error(xml->log, "Get len of the node failed!");                    stack_destroy(&stack);                    return -1;                }                len += len2;                child = child->next;            }            break;        }        case XML_NODE_ATTR:        case XML_NODE_UNKNOWN:        {            /* Do nothing */            len = 0;            break;        }    }    stack_destroy(&stack);    return len;}
开发者ID:object8421,项目名称:tanlz,代码行数:69,


示例6: calc_destroy

int calc_destroy(struct calc_info *info){	stack_destroy(info->num);	stack_destroy(info->opr);	free(info->num);	free(info->opr);	return 0;}
开发者ID:Shimejing,项目名称:demo_class,代码行数:9,


示例7: queue_destroy

void queue_destroy(queue_t *q){    // NULL-check the parameter    if (!q)        return;    // free up the stacks    stack_destroy(&(q->in));    stack_destroy(&(q->out));}
开发者ID:vhmth,项目名称:Lego-Box,代码行数:10,


示例8: calc_destroy

int calc_destroy(struct calc *calc){	assert(calc != NULL);	stack_destroy(calc->num);	stack_destroy(calc->opr);	free(calc->num);	free(calc->opr);	return 0;}
开发者ID:jiangzhiyongzh,项目名称:datastruct,代码行数:10,


示例9: main

int main () {    struct Stack *stack;    stack = stack_create (10);    char *c = calloc (16, sizeof (char));    char **str= calloc(1,sizeof(char*));    int n;    while(strcmp(c,"=")) {        scanf("%s", c);        if (strtol(c, str,  10))             stack_push (stack, strtol(c, str, 10));        else {            if (!strcmp(c, "+"))                 stack_push (stack, stack_pop(stack) + stack_pop (stack));            if (!strcmp(c, "-")) {                n = stack_pop(stack) - stack_pop (stack);                    stack_push (stack, -n);            }                                                                                   if (!strcmp(c, "*"))                    stack_push (stack, stack_pop(stack) * stack_pop (stack));                                                                           }           }    printf("%d/n", stack_pop(stack));    stack_destroy(stack);    free (str);    free (c);    return 0;}
开发者ID:terana,项目名称:ILove_Coding,代码行数:29,


示例10: test_stack

void test_stack(){    printf("/ntesting stack/n");        int c = 16;    struct stack* s = stack_create(c);    int num = 200;    for (int i = 0; i < num; ++i) {        stack_push(s, i);    }    while (!stack_empty(s)) {        printf("%d ", stack_pop(s));    }    printf("/nresize the stack and test it again/n");    for (int i = 0; i < num; ++i) {        stack_push(s, i);    }    stack_resize(s, 128);    for (int i = 0; i < num; ++i) {        stack_push(s, i);    }    while (!stack_empty(s)) {        printf("%d ", stack_pop(s));    }    stack_destroy(s);}
开发者ID:chengw1005,项目名称:alg_ex,代码行数:33,


示例11: test_stack_push

void test_stack_push(){    Stack *s = stack_new();    int a = 1;    int b = 2;    int c = 3;    stack_push(s, &a);    cc_assert(stack_peek(s) == &a,              cc_msg("stack_push: Top stack element not as expected"));    stack_push(s, &b);    cc_assert(stack_peek(s) == &b,              cc_msg("stack_push: Top stack element not as expected"));    stack_push(s, &c);    cc_assert(stack_peek(s) == &c,              cc_msg("stack_push: Top stack element not as expected"));    stack_destroy(s);}
开发者ID:3k,项目名称:Collections-C,代码行数:26,


示例12: _st_bst_destroy

static void_st_bst_destroy(st_bst_node_t *root){  st_bst_node_t **pcur;  stack_t        *stack;  // hypothesis: all calls for the stack would not be failed  stack = stack_init(128, g_item_op->null);  (void) stack_push(stack, &g_dummy);  for (pcur = &root; *pcur != g_dummy; ) {    if ((*pcur)->left==g_dummy && (*pcur)->right==g_dummy) {      _st_bst_free_node(*pcur);      *pcur = g_dummy;      // "g_dummy->right == dummy" gives the terminate condition      pcur = stack_peek(stack);      if ((*pcur)->right == g_dummy) {        pcur = stack_pop(stack);      } else {        pcur = &(*pcur)->right;      }    } else {      stack_push(stack, pcur);      if ((*pcur)->left != g_dummy) {        pcur = &(*pcur)->left;      } else {        pcur = &(*pcur)->right;      }    }  }  stack_destroy(stack);}
开发者ID:kiterunner-t,项目名称:krt,代码行数:34,


示例13: main

int main(void){	int i;	int* data[10];	Stack stack;	// 10 test data	for (i = 0; i< 10; i++)	{		data[i] = (int*)malloc(sizeof(int));		*data[i] = i;	}	stack = stack_create(debug_free);	//push data pointer	for (i = 0;i < 10 ;i++)	{		stack_push(stack,data[i]);		stack_debug(stack);	}		//pop data pointer	for (i = 0; i < 8 ;i++)	{		stack_pop(stack,&data[i]);		free(data[i]);		stack_debug(stack);	}	stack_destroy(stack);	return 0;}
开发者ID:mintist,项目名称:ADT-in-C,代码行数:35,


示例14: main

int main (int argc, const char * argv[]) {			//Stack		int numbers[NUMLEN] = {		15, 10, 5, 100	};		int i;	Stack *stack = stack_create();		for(i = 0; i < NUMLEN; i++) {		printf("pushing: %u/n", numbers[i]);		stack_push(stack, numbers[i]);	}		printf("/n");	stack_print(stack);	while(i--) {		unsigned int result = stack_pop(stack);		if(UINT_MAX == result) {			break;		}				printf("popping: %u/n", result);	}		stack_destroy(stack);		//Queue		Queue *queue = queue_create();		for(i = 0; i < NUMLEN; i++) {		printf("/nenqueueing: %u", numbers[i]);		queue_enqueue(queue, numbers[i]);	}		queue_print(queue);		while(i--) {		unsigned int result = queue_dequeue(queue);				if(UINT_MAX == result) {			break;		}				printf("dequeuing: %u/n", result);	}		queue_print(queue);	queue_destroy(queue);	return 0;}
开发者ID:jacobrelkin,项目名称:linked_list_with_blocks,代码行数:60,


示例15: mpi_send_stack

/** * MPI odeslani n-tiny vlastniho zasobniku prijemci dest. */void mpi_send_stack(const int n, int dest) {	assert(t);	assert(s);	unsigned int l;	char *b = NULL;	stack_t *sn = stack_divide(s, n);	b = stack_mpipack(sn, t, &l);	srpdebug("mpi", node, "odeslani zasobniku <s=%d, l=%db, dest=%d>",		sn->s, l, dest);	// ADUV	if(dest < node)		mpi_color = 1; // cerna	// poslat MSG_STACK s delkou zpravy se serializovanym zasobnikem	MPI_Send(&l, 1, MPI_INT, dest, MSG_STACK, MPI_COMM_WORLD);	// poslat serializovany zasobnik	MPI_Send(b, l, MPI_PACKED, dest, MSG_STACK_DATA, MPI_COMM_WORLD);	stack_destroy(sn);	free(b);}
开发者ID:blami,项目名称:mi-par,代码行数:28,


示例16: main

int main(void){    int a[10];    int i;    int data;    rand_a(a, 10);    show_a(a, 10);    stack_t *st = stack_create(sizeof(int), NULL);    printf("====== push ======/n");    for (i = 0; i < 10; i++)        stack_push(st, &a[i]);    printf("====== top ======/n");    stack_top(st, &data);    printf("top : %d/n", data);    printf("====== pop ======/n");    //while (!stack_isempty(st))    {        stack_pop(st, &data);        printf("%d ", data);    }    putchar('/n');    stack_destroy(st);    return 0;}
开发者ID:royye62,项目名称:mydemo,代码行数:31,


示例17: main

int main(int argc, char *argv[]){    stack_t *stack = NULL;    bst_node_t **bst_arr = NULL;    bst_node_t *tmp = NULL;    bst_arr = debug_stack_bst_array();    stack = stack_init(5);    for(unsigned int i = 0; i < BST_ARRAY_SIZE; i++) {        printf("Stack #%d/n", i);        printf("Push nodes: ");        debug_stack_print_bst(bst_arr[i]);        stack_push_node(stack, bst_arr[i]);        printf("/n/n");    }    puts("Final stack: ");    debug_stack_print(stack);    printf("/nEquality tests: /n");    for(int i = BST_ARRAY_SIZE - 1; i >= 0; i--) {        tmp = stack_pop_node(stack);        if(debug_stack_bst_compare(tmp, bst_arr[i]))            printf("[Stack #%d] PASS - BSTs are equal/n", i);        else            printf("[Stack #%d] FAIL - BSTs are not equal/n", i);    }    stack_destroy(stack);    debug_stack_bst_array_destroy(bst_arr);    return 0;}
开发者ID:mrc0mmand,项目名称:ifj2015,代码行数:34,


示例18: main

int main() {	Stack *pila1;	pila1 = stack_create();		stack_data(pila1)[0] = 2;	stack_data(pila1)[1] = 8;	stack_data(pila1)[2] = 14;	stack_back(pila1) = 2;	pila1 = stack_push(pila1,4);	pila1 = stack_pop(pila1);	stack_print(pila1);		int i;	for(i = 0; i<=stack_back(pila1) && stack_back(pila1) != stack_maxstack(pila1) ; i++)				stack_data(pila)[i] = 3;	pila1 = stack_reverse(pila1);	stack_print(pila1);	stack_destroy(pila1);	}
开发者ID:laurofigueroa,项目名称:EDyA1,代码行数:30,


示例19: post_order_norec

static inline void post_order_norec(struct btree *btree, 		void (*todo)(struct bnode *)){	struct stack stack; //定义栈变量	stack_init(&stack);	struct bnode *tmp = NULL; //用来记录cur指向的节点的右孩子是否之前已经被todo过	struct bnode *cur = btree->root;	while (!stack.is_empty(&stack) || cur) { //栈不为空或者cur指向的节点还存在		if (cur) {			stack.push(&stack, cur);			cur = cur->lchild;		} else {			cur = stack.top(&stack);			if ((cur->rchild) && (cur->rchild != tmp)) { //cur节点的右孩子存在,并且该节点之前没有被todo过				cur = cur->rchild;			} else {				cur = stack.pop(&stack);				todo(cur);				tmp = cur;				cur = NULL;			}		}	}	stack_destroy(&stack);}
开发者ID:sktwj,项目名称:var,代码行数:28,


示例20: stk_test_pop

void stk_test_pop(void) {	stack_t* s = stack_init(stk_compare, stk_print, stk_clone, stk_destroy);	CU_ASSERT (s != NULL);		CU_ASSERT (stack_push(s, stk_test_s1) != NULL);;	CU_ASSERT (stack_push(s, stk_test_s2) != NULL);;	CU_ASSERT (stack_push(s, stk_test_s3) != NULL);;	CU_ASSERT (stack_push(s, stk_test_s4) != NULL);;	char* str = stack_pop(s);	CU_ASSERT(str != stk_test_s4);	CU_ASSERT (strcmp(str, stk_test_s4) == 0);	free(str);	str = stack_pop(s);	CU_ASSERT(str != stk_test_s3);	CU_ASSERT (strcmp(str, stk_test_s3) == 0);	free(str);	str = stack_pop(s);	CU_ASSERT(str != stk_test_s2);	CU_ASSERT (strcmp(str, stk_test_s2) == 0);	free(str);	str = stack_pop(s);	CU_ASSERT(str != stk_test_s1);	CU_ASSERT (strcmp(str, stk_test_s1) == 0);	free(str);	str = stack_pop(s);	CU_ASSERT(str == NULL);	CU_ASSERT(stack_size(s) == 0);		CU_ASSERT (stack_destroy(s) == 0);}
开发者ID:juliensimon,项目名称:data-structures,代码行数:35,


示例21: bst_inOrder

int bst_inOrder(const BisTree *pTree, BNode *pStartNode, Queue *qInorder) {		Stack stNodes;	BNode *pNode;		if (pStartNode == 0 || qInorder == 0)		return -1;		pNode = pStartNode;	stack_init(&stNodes, 0);		REPEAT:	while (pNode != 0) {		stack_push(&stNodes, (const void *) pNode);		pNode = bst_leftChild((const BNode *) pNode);	}		if (stack_size(&stNodes) > 0) {		stack_pop(&stNodes, (void **) &pNode);		queue_enqueue(qInorder, (const void *) pNode);		pNode = bst_rightChild((const BNode *) pNode);		goto REPEAT;	}		stack_destroy(&stNodes);	return 0;}
开发者ID:AKD92,项目名称:Binary-Search-Tree-Based-Dictionary-ADT,代码行数:27,


示例22: sort_stack

int sort_stack(struct stack *s) {	struct stack *t = stack_create();	while(!is_empty(s)) {		int min = top(s), n = 0;		int i;		int c = 0;		while(!is_empty(s)) {			int k = pop(s);			if(k < min) min = k;			push(t, k);			c++;		}		for(i=0; i<c; i++) {			int k = pop(t);			if(k == min) n++;			else push(s, k);		}		for(i=0; i<n; i++) push(t, min);	}	while(!is_empty(t)) {		push(s, pop(t));	}	stack_destroy(t);	return 0;}
开发者ID:hmeng-19,项目名称:CUtils,代码行数:29,


示例23: main

int main() {	struct stack *s = stack_create();	assert(is_empty(s));	push(s, 5);	push(s, 20);	push(s, 1);	push(s, 20);	push(s, 12);	push(s, 12);	push(s, 12);	push(s, 39);	push(s, 20);	//sort_stack(s);	sort_stack_1(s);	fprintf(stdout, "the sorted stack are:/n");	while(!is_empty(s)) {		fprintf(stdout, "%d/n", pop(s));	}	assert(is_empty(s));	stack_destroy(s);	return 0;}
开发者ID:hmeng-19,项目名称:CUtils,代码行数:25,


示例24: cleanup

static void cleanup(void){    ir_destroy();    node_destroy(root);    stack_destroy(&stack);    yylex_destroy();}
开发者ID:edvardsp,项目名称:kompilates,代码行数:7,


示例25: main

int main(void){	STACK *stack;	struct score tmp;	int i;	int ret;	stack = stack_creat(sizeof(struct score));	/* if error */	for (i = 0; i < 9; i++) {		tmp.id = i;		snprintf(tmp.name, NAMESIZE, "stu%d", i);		tmp.ch = 100 - i;		stack_push(stack, &tmp);		/* if error */	}	while (1) {		ret = stack_pop(stack, &tmp);		if (ret == -1) {			break;		}		printf("%d, %s, %d/n", tmp.id, tmp.name, tmp.ch);	}	stack_destroy(stack);	return 0;}
开发者ID:zyxstar,项目名称:exam_c,代码行数:32,


示例26: test_stack_push

int test_stack_push(void){    struct stack *s = stack_new();    float *f1 = malloc_float(2.0);    float *f2 = malloc_float(4.0);    float *f3 = malloc_float(8.0);    /* push float 1 */    stack_push(s, f1);    mu_check(fltcmp(s->end->value, f1) == 0);    mu_check(s->size == 1);    mu_check(s->root->value == f1);    mu_check(s->end->prev == NULL);    /* push float 2 */    stack_push(s, f2);    mu_check(fltcmp(s->end->value, f2) == 0);    mu_check(s->size == 2);    mu_check(s->root->value == f1);    mu_check(s->end->prev->value == f1);    mu_check(fltcmp(s->end->prev->value, f1) == 0);    /* push float 3 */    stack_push(s, f3);    mu_check(fltcmp(s->end->value, f3) == 0);    mu_check(s->size == 3);    mu_check(s->root->value == f1);    mu_check(s->end->prev->value == f2);    mu_check(fltcmp(s->end->prev->value, f2) == 0);    stack_destroy(s, free);    return 0;}
开发者ID:wallarelvo,项目名称:evolve,代码行数:33,


示例27: main

int main(int argc, char **argv){	t_stack *stack_a;	t_stack *stack_b;	int i;	i = 0;	stack_a = (t_stack *)malloc(sizeof(t_stack));	stack_init(stack_a, argc);	stack_b = (t_stack *)malloc(sizeof(t_stack));	stack_init(stack_b, argc);	stack_fill(stack_a, argv);	set_stack_b(stack_b, stack_a);	stack_ra(stack_a);	ft_putstr("Popped characters are: /n");	while (i <= stack_a->top)	{		ft_putstr(ft_itoa(stack_a->content[i]));		ft_putchar('/n');		i++;	}/*	i = 0;	stack_pb(stack_a, stack_b);		ft_putstr("------------------/n");	while (i < stack_b->max_size - 1 && stack_b->content[i] != -1)	{		ft_putstr(ft_itoa(stack_b->content[i]));		ft_putchar('/n');		i++;	}*/	stack_destroy(stack_a);}
开发者ID:tonmanayo,项目名称:push_swap,代码行数:33,


示例28: bst_preOrder

int bst_preOrder(const BisTree *pTree, BNode *pStartNode, Queue *qPreorder) {		Stack stNodes;	int isInternal;	const BNode *pNode;	const BNode *pLeftChild, *pRightChild;		if (pStartNode == 0 || qPreorder == 0)		return -1;		pNode = 0;	pLeftChild = pRightChild = 0;	stack_init(&stNodes, 0);	stack_push(&stNodes, (const void *) pStartNode);		while (stack_size(&stNodes) > 0) {				stack_pop(&stNodes, (void **) &pNode);		queue_enqueue(qPreorder, (const void *) pNode);		isInternal = bst_isInternal(pNode);				if (isInternal == 1) {			pRightChild = bst_rightChild(pNode);			pLeftChild = bst_leftChild(pNode);			stack_push(&stNodes, (const void *) pRightChild);			stack_push(&stNodes, (const void *) pLeftChild);		}	}		stack_destroy(&stNodes);	return 0;}
开发者ID:AKD92,项目名称:Binary-Search-Tree-Based-Dictionary-ADT,代码行数:32,



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


C++ stack_free函数代码示例
C++ stackValue函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。