这篇教程C++ stack_is_empty函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中stack_is_empty函数的典型用法代码示例。如果您正苦于以下问题:C++ stack_is_empty函数的具体用法?C++ stack_is_empty怎么用?C++ stack_is_empty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了stack_is_empty函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(int argc, char ** argv){ if (argc < 2) { printf("Usage: rpncalc op1 op2 .../n"); exit(1); } STACK * s = stack_create(); int i; char * c; for (i = 1; i < argc; i++) { if (is_operand(c = argv[i])) { if (stack_is_empty(s)) { printf("Elements remain in the stack./n"); exit(1); } else { compute_operation(s, c); } } else { stack_push(s, atof(c)); } } double result = s->top->val; stack_pop(s); if(stack_is_empty(s)) { printf("%f/n", result); } else { printf("Elements remain in the stack./n"); } exit(0);}
开发者ID:nalliso,项目名称:purduecs,代码行数:34,
示例2: test_pop_with_no_datastatic void test_pop_with_no_data(void){ struct stack *s = NULL; s = stack_push(s, CHAR_TO_PTR('a')); assert(!stack_is_empty(s)); s = stack_pop(s, NULL); assert(stack_is_empty(s));}
开发者ID:jsitnicki,项目名称:saw-sharpening,代码行数:10,
示例3: test_pop_from_emptystatic void test_pop_from_empty(void){ struct stack *s = NULL; void *data = CHAR_TO_PTR('x'); assert(stack_is_empty(s)); s = stack_pop(s, &data); assert(stack_is_empty(s)); assert(PTR_TO_CHAR(data) == 'x');}
开发者ID:jsitnicki,项目名称:saw-sharpening,代码行数:11,
示例4: test_push_a_pop_astatic void test_push_a_pop_a(void){ struct stack *s = NULL; void *data = NULL; s = stack_push(s, CHAR_TO_PTR('a')); assert(!stack_is_empty(s)); s = stack_pop(s, &data); assert(stack_is_empty(s)); assert(PTR_TO_CHAR(data) == 'a');}
开发者ID:jsitnicki,项目名称:saw-sharpening,代码行数:12,
示例5: mainint main(int argc, char **argv) { int op; int number; stack_t st; stack_init(&st, INITIAL_STACK_SIZE); while ((op = get_next_operation(stdin, &number)) != OP_STACK_END) { if (op == OP_STACK_PUSH) { stack_push(&st, number); } else if (op == OP_STACK_POP) { if (stack_is_empty(&st)) { printf("POP from empty stack./n"); } else { printf("%d/n", stack_pop(&st)); } } else { fprintf(stderr, "Unexpected operation./n"); stack_free(&st); exit(EXIT_FAILURE); } } stack_free(&st); return EXIT_SUCCESS;}
开发者ID:errbufferoverfl,项目名称:algorithms_and_analysis,代码行数:30,
示例6: double_treevoid double_tree(struct bitree *tree){ struct bitree_node *node = tree->root; struct bitree_node *last_visited = NULL, *peek; struct stack_t parent_stack, *parent = &parent_stack; if (tree == NULL) return; stack_init(parent, NULL); while (!stack_is_empty(parent) || node) { if (node) { stack_push(parent, (const void *) node); node = node->left; } else { peek = (struct bitree_node *) stack_peek(parent); if (peek->right && last_visited != peek->right) { node = peek->right; } else { double_tree_node(tree, peek); stack_pop(parent, (void **) &last_visited); } } }}
开发者ID:jonaschen,项目名称:C-Programming-Library,代码行数:26,
示例7: __assert_convert_loadstatic void __assert_convert_load(unsigned char *code, unsigned long code_size, enum vm_type expected_type, unsigned char expected_index){ struct expression *expr; struct statement *stmt; struct basic_block *bb; bb = alloc_simple_bb(code, code_size); convert_to_ir(bb->b_parent); expr = stack_pop(bb->mimic_stack); assert_temporary_expr(expected_type, &expr->node); stmt = stmt_entry(bb->stmt_list.next); assert_store_stmt(stmt); assert_local_expr(expected_type, expected_index, stmt->store_src); assert_ptr_equals(&expr->node, stmt->store_dest); assert_true(stack_is_empty(bb->mimic_stack)); expr_put(expr); free_simple_bb(bb);}
开发者ID:siam,项目名称:jato,代码行数:27,
示例8: assert_convert_ldc_w_floatstatic void assert_convert_ldc_w_float(enum vm_type expected_type, double expected_value, uint8_t cp_type, unsigned long opcode){ unsigned char code[] = { opcode, 0x01, 0x00 }; uint32_t cp_infos[NR_CP_ENTRIES]; uint8_t cp_types[NR_CP_ENTRIES]; struct expression *expr; struct basic_block *bb; if (opcode == OPC_LDC_W) const_set_float(cp_infos, 0x100, (float) expected_value); else const_set_double(cp_infos, 0x100, expected_value); cp_types[0x100] = cp_type; bb = alloc_simple_bb(code, ARRAY_SIZE(code)); convert_ir_const(bb->b_parent, cp_infos, NR_CP_ENTRIES, cp_types); expr = stack_pop(bb->mimic_stack); assert_fvalue_expr(expected_type, expected_value, &expr->node); assert_true(stack_is_empty(bb->mimic_stack)); expr_put(expr); free_simple_bb(bb);}
开发者ID:siam,项目名称:jato,代码行数:26,
示例9: mainint main(){ unsigned int i; int tmp; Stack s; int test_data[SIZE] = {7,8,6,10,5,4,12,3,13,12}; init_stack(&s); for(i = 0; i < SIZE; i++) { stack_push(&s, test_data[i]); } printf(">>>>>>start to pop/n"); while(!stack_is_empty(&s)) { if(get_min(&s, &tmp)) printf("min is %d/n", tmp); stack_pop(&s, &tmp); printf("%d/n", tmp); } return 0;}
开发者ID:gtvforever,项目名称:c,代码行数:25,
示例10: inorderTraversalint * inorderTraversal(struct TreeNode *root, int *returnSize){ int idx, *list = (int *)malloc(sizeof(int) * 256); /* ~~, implement a list? */ struct TreeNode *node; Stack *stack = stack_new(sizeof(struct TreeNode *)); idx = 0; node = root; while (node != NULL) { stack_push(stack, &node); node = node->left; } while (!stack_is_empty(stack)) { stack_pop(stack, &node); list[idx++] = node->val; node = node->right; while (node != NULL) { stack_push(stack, &node); node = node->left; } } stack_free(stack); *returnSize = idx; return list;}
开发者ID:damnever,项目名称:Note,代码行数:26,
示例11: postorder_stackvoid postorder_stack(int * tree, int root){ int ptr = root; while (tree[ptr] != -1) { push(ptr); /* If right child exists, push its index(multipled by -1) into the stack */ if ( tree[2*ptr + 2] != -1 ) push( -(2*ptr + 2) ); if (tree[2*ptr + 1] != -1) ptr = 2*ptr + 1; else { while(1) { if ( stack_is_empty() ) return; ptr = pop(); if (ptr < 0) { ptr *= -1; break; } printf("%c ", tree[ptr]); } } }}
开发者ID:harsh1kumar,项目名称:learning,代码行数:33,
示例12: ct_index_ofextern intct_index_of(node_t *root, PyObject *key){ node_t *node = root; int index = 0; int go_down = 1; node_stack_t *stack; stack = stack_init(32); for (;;) { if ((LEFT_NODE(node) != NULL) && go_down) { stack_push(stack, node); node = LEFT_NODE(node); } else { if (ct_compare(KEY(node), key) == 0) { stack_delete(stack); return index; } index++; if (RIGHT_NODE(node) != NULL) { node = RIGHT_NODE(node); go_down = 1; } else { if (stack_is_empty(stack)) { stack_delete(stack); return -1; } node = stack_pop(stack); go_down = 0; } } }}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:35,
示例13: stack_topchar stack_top(struct stack *s){ if (stack_is_empty(s)) return 0; return *(s->buffer + s->top);}
开发者ID:bcho,项目名称:homework,代码行数:7,
示例14: TestStackCreationvoid TestStackCreation(CuTest* tc) { struct Stack* stack = stack_new(16); CuAssertIntEquals(tc, 16, stack->size); CuAssertTrue(tc, stack_is_empty(stack)); stack_del(stack);}
开发者ID:seece,项目名称:tiraimg,代码行数:7,
示例15: assert_dup_x2_stackstatic void assert_dup_x2_stack(unsigned char opc, struct expression *value1, struct expression *value2, struct expression *value3){ struct basic_block *bb; struct statement *stmt; bb = alloc_simple_bb(&opc, 1); stack_push(bb->mimic_stack, expr_get(value3)); stack_push(bb->mimic_stack, expr_get(value2)); stack_push(bb->mimic_stack, expr_get(value1)); convert_to_ir(bb->b_parent); stmt = stmt_entry(bb->stmt_list.next); assert_store_stmt(stmt); assert_ptr_equals(value1, to_expr(stmt->store_src)); assert_temporary_expr(value1->vm_type, stmt->store_dest); assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack)); assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack)); assert_ptr_equals(value3, pop_and_put_expr(bb->mimic_stack)); assert_ptr_equals(value1, pop_and_put_expr(bb->mimic_stack)); assert_true(stack_is_empty(bb->mimic_stack)); free_simple_bb(bb);}
开发者ID:code-in-the-shell,项目名称:jato,代码行数:28,
示例16: mainint main(void) { Stack *ps = InitStack(); int i,item; int x[15]; printf("please input 10 numbers/n"); printf("test stack_push() and GetTop()/n"); for(i=0;i<10;i++) { scanf("%d",&x[i]); stack_push(ps,i); GetTop(ps,&item); printf("%d ",item); } printf("/ntest stack_pop()/n"); for(i=0;i<10;i++) { stack_pop(ps,&item); printf("%d ",item); } if(stack_is_empty(ps)) printf("/nthis stack is empty!"); return 0;}
开发者ID:huihuizhang,项目名称:Linux101,代码行数:26,
示例17: print_pathsint print_paths(struct bitree_node *root){ struct bitree_node *node = root, *dummy; struct bitree_node *last_visited = NULL, *peek; struct stack_t parent_stack, *parent = &parent_stack; struct stack_t path_stack, *paths = &path_stack; int cnt = 0; stack_init(parent, NULL); stack_init(paths, NULL); while (!stack_is_empty(parent) || node) { if (node) { stack_push(parent, (const void *) node); stack_push(paths, (const void *) node); node = node->left; } else { peek = (struct bitree_node *) stack_peek(parent); if (peek->right && last_visited != peek->right) { node = peek->right; } else { if (!peek->right && (peek->left != last_visited || !peek->left)) { fprintf(stdout, "path %d:", ++cnt); print_path_sum(paths); } stack_pop(parent, (void **) &last_visited); stack_pop(paths, (void **) &dummy); } } } return cnt;}
开发者ID:jonaschen,项目名称:C-Programming-Library,代码行数:33,
示例18: printvoid ValueStack::print() { if (stack_is_empty()) { tty->print_cr("empty stack"); } else { InstructionPrinter ip; for (int i = stack_size(); i > 0;) { Value t = stack_at_dec(i); tty->print("%2d ", i); ip.print_instr(t); tty->cr(); } } if (!no_active_locks()) { InstructionPrinter ip; for (int i = locks_size() - 1; i >= 0; i--) { Value t = _locks.at(i); tty->print("lock %2d ", i); if (t == NULL) { tty->print("this"); } else { ip.print_instr(t); } tty->cr(); } }}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:26,
示例19: test_initial_statestatic char * test_initial_state() { stack_reset(); /* test multiple braces */ sprintf(msg, "ERROR: %d: init_state: should not be empty", __LINE__); mu_assert(msg, stack_is_empty()); sprintf(msg, "ERROR: %d: init_state: should not be full", __LINE__); mu_assert(msg, ! stack_is_full()); push(1); sprintf(msg, "ERROR: %d: init_state: should not be empty", __LINE__); mu_assert(msg, ! stack_is_empty()); sprintf(msg, "ERROR: %d: init_state: should not be full", __LINE__); mu_assert(msg, ! stack_is_full()); return EXIT_SUCCESS;}
开发者ID:quux00,项目名称:midcutils,代码行数:16,
示例20: mainint main(void) { int x; void stack_push(int x);int stack_pop();int stack_capacity();int stack_size();int stack_is_empty();int stack_is_full(); while ( ! stack_is_full() ) { scanf("%d", &x); stack_push(x); } while ( !stack_is_empty() ) { x = stack_pop(); printf("%d/t", x); } printf("/n"); return 0;}
开发者ID:john9519,项目名称:C2016_exam,代码行数:26,
示例21: infix_to_profix_readvoid infix_to_profix_read(STACK * inputStack, STACK * outputStack, char * str){ char *p = str; int value = 0; while(*p != '/0') { if(' ' != *p) { if(true == infix_to_profix_is_number(*p)) { printf("%c ", *p); profix_expression_in(outputStack, p); } else { infix_to_profix_is_symbol(inputStack, outputStack, *p); } } p = p + 1; } while(true != stack_is_empty(inputStack)) { value = stack_pop(inputStack); printf("%c ", value); profix_expression_in(outputStack, &value); }}
开发者ID:Timsley,项目名称:DataStructures,代码行数:30,
示例22: stack_checkStackNode * stack_check(Stack * stack) { if (stack_is_empty(stack)) { return NULL; } else { return stack->head; }}
开发者ID:carlaguillen,项目名称:Compie,代码行数:8,
示例23: evaluate_RPNdouble evaluate_RPN(char *expr, struct stackNode **top){ int i, j = 0; double popVal1; // Stack'ten cikaracaginiz (pop) ilk deger double popVal2; // Stack'ten cikaracaginiz (pop) ikinci deger double pushVal; // Stack'e ekleyeceginiz (push) deger double retval = 0; char Val[20]; /* TODO: Ifadenin sonuna kadar elemanlari gezecek ('/0') bir dongu kurunuz */ for (i = 0; i < strlen(expr); i++) { /* TODO: Eger eleman islenen (operand) ise stack'e ekleyiniz (push) * Soru: Bir karakterin sayi karsiligini nasil buluyorduk? */ if (expr[i] == ' ') { Val[j + 1] = '/0'; j = 0; popVal1 = atof(Val); stack_push(top, popVal1); if (DEBUG) stack_print(*top); } else if (expr[i] == '/' || expr[i] == '*' || expr[i] == '-' || expr[i] == '+') { popVal1 = stack_pop(top); popVal2 = stack_pop(top); pushVal = compute_operation(popVal2, popVal1, expr[i]); stack_push(top, pushVal); i++; if (DEBUG) stack_print(*top); } else { /* TODO: Eger eleman bir islem ise stack'ten iki deger cekiniz (pop) */ Val[j] = expr[i]; j++; if (DEBUG) stack_print(*top); /* TODO: Bu iki deger ile istenen islemi compute_operation() * fonksiyonuna verip donus degeri stack'e push edin. */ if (DEBUG) stack_print(*top); } } /* TODO: Stack'te kalan elemani cekip return edin. */ retval = stack_pop(top); if (!stack_is_empty(*top)) { fprintf(stderr, "UYARI: Stack hala dolu, RPN ifadesi dengesiz veya algoritmayi yanlis kurdunuz./n"); } return retval;}
开发者ID:galatasarayuniversity,项目名称:INF203,代码行数:57,
示例24: stack_array_ops_popstatic struct data_node * stack_array_ops_pop(struct stack *stack){ struct stack_array *a_stack_array = container_of(stack, typeof(*a_stack_array), stack); _MY_TRACE_STR("stack_array::pop()/n"); if (!stack_is_empty(stack)) return a_stack_array->arr[--a_stack_array->top]; return 0;}
开发者ID:Coldrain,项目名称:Design-Patterns-in-C,代码行数:9,
示例25: stack_popint stack_pop(){ int e; if(!stack_is_empty()) e=--s.top; return e; else return error;
开发者ID:john9519,项目名称:C2016_exam,代码行数:9,
示例26: infix_to_profix_is_symbolvoid infix_to_profix_is_symbol(STACK * inputStack, STACK * outputStack, char str){ char value = 0; if('(' == str) { stack_push(inputStack, str); } else if(')' == str) { while((true != stack_is_empty(inputStack)) && ('(' != stack_top(inputStack)) ) { value = stack_pop(inputStack); printf("%c ", value); profix_expression_in(outputStack, &value); } stack_pop(inputStack); // pop ')' } else if('+'==str || '-'==str) { // pop the low or the same priority string in the Stack while((true != stack_is_empty(inputStack)) && ('(' != stack_top(inputStack))) { value = stack_pop(inputStack); printf("%c ", value); profix_expression_in(outputStack, &value); } stack_push(inputStack, str); } else if('*'==str || '/'==str) { // pop the low or the same priority string in the Stack while((true != stack_is_empty(inputStack)) && ('*'==stack_top(inputStack) || '/'==stack_top(inputStack))) { value = stack_pop(inputStack); printf("%c ", value); profix_expression_in(outputStack, &value); } stack_push(inputStack, str); }}
开发者ID:Timsley,项目名称:DataStructures,代码行数:44,
示例27: stack_popCharVector stack_pop(Stack *sp) { if (stack_is_empty(sp)) error("an attempt to pop from empty stack"); StackElement *tmp = sp->top; CharVector popped = tmp->data; sp->top = sp->top->next; free(tmp); sp->size--; return popped;}
开发者ID:arssher,项目名称:sphere,代码行数:10,
示例28: minx_opc_drop_func/* * Command: DROP * Parameters: 0 * Affects Program Pointer: NO * * Remove element from stack * */void minx_opc_drop_func(uint64_t *params) {#ifdef DEBUGGING /*no explaining here, nothing to explain*/#endif if( stack_is_empty( stack ) ) { FATAL_DESC_ERROR("Cannot drop from empty stack!"); } stackpop(stack);}
开发者ID:iddumied,项目名称:minx,代码行数:18,
示例29: WARNINGelement_class *stack_pop(stack_class *stack){ if(stack_is_empty(stack)) { WARNING("Cannot pop element because stack is empty"); return NULL; } return &(stack->elements[stack->top--]);}
开发者ID:ntrtrung,项目名称:eBATMAN,代码行数:10,
示例30: stack_pop// Removes the element at the top of the stackvoid stack_pop(STACK * stack) { NODE * temp = (NODE *)malloc(sizeof(NODE)); if (stack_is_empty(stack)) { printf("Cannot Pop Empty Stack/n"); } else { temp = stack->top->prev; free(stack->top); stack->top = temp; }}
开发者ID:nalliso,项目名称:purduecs,代码行数:11,
注:本文中的stack_is_empty函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ stack_new函数代码示例 C++ stack_init函数代码示例 |