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

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

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

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

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

示例1: load_stack

static voidload_stack(void){	struct stack *stack;	struct value *value;	int idx;	idx = readreg();	if (idx >= 0) {		stack = &bmachine.reg[idx];		value = NULL;		if (stack_size(stack) > 0) {			value = stack_pop(stack);		}		if (value != NULL)			push(value);		else			warnx("stack register '%c' (0%o) is empty",			    idx, idx);	}}
开发者ID:coyizumi,项目名称:cs111,代码行数:21,


示例2: main

int main(){	srand(time(NULL));	stack_t s;	stack_create(&s, sizeof(int));	int i;	for(i=0; i<N; i++){		int temp = rand()%N; 		printf("push: %d/n", temp);		stack_push(&s, &temp);	}	int data;	while( (stack_pop(&s, &data) == GERROR_OK) )		printf("pop: %d/n", data);	stack_destroy(&s);	return 0;}
开发者ID:yudi-matsuzake,项目名称:libgenerics,代码行数:21,


示例3: main

int main() {	int n;	Stack* s = stack_create(1);	stack_push(s, 42);	stack_push(s, 37);	stack_pop(s);	stack_push(s, 20);	stack_push(s, -3);	n = stack_size(s);	printf("%d/n", n);	stack_destroy(s);	List_stack* ls = list_stack_create();	list_stack_push(ls, 42);	list_stack_push(ls, 37);	list_stack_push(ls, -3);	list_stack_pop(ls);	n = list_stack_size(ls);	printf("%d/n", n);	list_stack_destroy(ls);}
开发者ID:Ejikpyroman,项目名称:NSULabs-2,代码行数:21,


示例4: load_stack

static voidload_stack(void){	int		index;	struct stack	*stack;	struct value	*value, copy;	index = readreg();	if (index >= 0) {		stack = &bmachine.reg[index];		value = NULL;		if (stack_size(stack) > 0) {			value = stack_pop(stack);		}		if (value != NULL)			push(stack_dup_value(value, &copy));		else			warnx("stack register '%c' (0%o) is empty",			    index, index);	}}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:21,


示例5: radix_tree_item_destroy

/** * Remove an item. Remove also all its children if the parameter * 'iSingle' is 1. */void radix_tree_item_destroy(_radix_tree_item_t ** ptree_item,			     FRadixTreeDestroy fDestroy,			     int iSingle){  gds_stack_t * stack= stack_create(32);  _radix_tree_item_t * tree_item= *ptree_item;  while (tree_item != NULL) {    /* If all children are to be removed, push them onto stack. */    if (!iSingle) {      if (tree_item->left != NULL)	stack_push(stack, tree_item->left);      if (tree_item->right != NULL)	stack_push(stack, tree_item->right);    }    /* Destroy the item. */    if ((tree_item->data != NULL) && (fDestroy != NULL)) {      fDestroy(&tree_item->data);      tree_item->data= NULL;    }    /* If the current item is empty (no child) or if we delete all       child, then free the item's memory. */    if (((tree_item->left == NULL) && (tree_item->right == NULL)) ||	!iSingle) {      FREE(tree_item);      *ptree_item= NULL;    }    /* Any other child to be removed ? */    if (stack_depth(stack) > 0)      tree_item= (_radix_tree_item_t *) stack_pop(stack);    else      tree_item= NULL;  }  stack_destroy(&stack);}
开发者ID:UCASREN,项目名称:Crossbear,代码行数:44,


示例6: media_entity_graph_walk_next

/** * media_entity_graph_walk_next - Get the next entity in the graph * @graph: Media graph structure * * Perform a depth-first traversal of the given media entities graph. * * The graph structure must have been previously initialized with a call to * media_entity_graph_walk_start(). * * Return the next entity in the graph or NULL if the whole graph have been * traversed. */struct media_entity *media_entity_graph_walk_next(struct media_entity_graph *graph){	if (stack_top(graph) == NULL)		return NULL;	/*	 * Depth first search. Push entity to stack and continue from	 * top of the stack until no more entities on the level can be	 * found.	 */	while (link_top(graph) < stack_top(graph)->num_links) {		struct media_entity *entity = stack_top(graph);		struct media_link *link = &entity->links[link_top(graph)];		struct media_entity *next;		/* The link is not enabled so we do not follow. */		if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {			link_top(graph)++;			continue;		}		/* Get the entity in the other end of the link . */		next = media_entity_other(entity, link);		if (WARN_ON(next->id >= MEDIA_ENTITY_ENUM_MAX_ID))			return NULL;		/* Has the entity already been visited? */		if (__test_and_set_bit(next->id, graph->entities)) {			link_top(graph)++;			continue;		}		/* Push the new entity to stack and start over. */		link_top(graph)++;		stack_push(graph, next);	}	return stack_pop(graph);}
开发者ID:03199618,项目名称:linux,代码行数:52,


示例7: graph_dfs

/* returns 0 on no cycle, -1 on cycle */int graph_dfs(struct graph *graph, int root, struct stack *topost){	graph->vertices[root].color = GRAY;	struct vertex *curv, *next;	struct stack *st = stack_new(sizeof(struct vertex *));	int ret = 0;	int pos;	curv = graph->vertices + root;	stack_push(st, &curv);	while (!stack_empty(st)) {		stack_peek(st, &curv);		if (curv->dfs_idx >= curv->nr) {			curv->color = BLACK;			pos = vindex_lookup(graph, curv->data);			stack_push(topost, &pos);			stack_pop(st, &curv);			continue;		}		next = vertex_get_next_edge(graph, curv);		if (next->color == GRAY) {			ret = -1;			if (graph_debug_resolve) {				const char *visiting_pkg = curv->data;				const char *visited_pkg = next->data;				fprintf(stderr, "Cyclic dep with %s -> ... -> %s -> %s/n",						visited_pkg, visiting_pkg, visited_pkg);			}			break;		} else if (next->color == WHITE) {			next->color = GRAY;			stack_push(st, &next);		}	}	stack_free(st);	return ret;}
开发者ID:Berticus,项目名称:powaur,代码行数:41,


示例8: AUTO_ROOT

/* * Parse the input stream and return an action stack. * See Wikipedia again. */static obj_t *parse(instream_t *in){    AUTO_ROOT(actions, NIL);    AUTO_ROOT(yylval, NIL);    AUTO_ROOT(tmp, make_fixnum(TOK_EOF));    AUTO_ROOT(stack, NIL);    stack_push(&stack, tmp);    tmp = make_fixnum(sym_index(start_symbol));    stack_push(&stack, tmp);    int tok = yylex(&yylval, in);    while (true) {	int sym = fixnum_value(stack_pop(&stack));	assert(0 <= sym && sym < symbols_size);	uint_fast8_t rule = get_rule(symbols[sym], tok);	if (rule != NO_RULE) {	    const production_t *pp = &grammar[rule];	    int j;	    for (j = strlen(pp->p_rhs); --j >= 0; ) {		tmp = make_fixnum(sym_index(pp->p_rhs[j]));		stack_push(&stack, tmp);	    }	    if (pp->p_action)		stack_push(&actions, *pp->p_action);	} else {	    if (sym == TOK_EOF)		break;	    /* XXX raise an exception here. */	    assert(sym == tok && "syntax error");	    if (!is_null(yylval))		stack_push(&actions, yylval);	    if (!stack_is_empty(actions) &&		fixnum_value(stack_top(stack)) == TOK_EOF)		break;	    yylval = NIL;	    tok = yylex(&yylval, in);	}    }    POP_FUNCTION_ROOTS();    return actions;}
开发者ID:kbob,项目名称:kbscheme,代码行数:44,


示例9: average

void * average() {	/*   Récupération des variables pour la condition de fin   */	pthread_mutex_lock(&files);	pthread_mutex_lock(&newfract);	pthread_mutex_lock(&finished);	int flag = flagFiles;	int nread = readFract;	int nfinished = finishedFract;	pthread_mutex_unlock(&files);	pthread_mutex_unlock(&newfract);	pthread_mutex_unlock(&finished);	struct fractal *bestAv = fractal_new("empty", 1, 1, 0.0, 0.0); //Variable où stocker la meilleure fractale	while (!flag || nread != nfinished) { //Tant qu'il y a des fichiers à lire ou que le nombre de fractales créées est différent du nombre de fracales terminées		sem_wait(&full2); //On attend qu'il y ait quelque chose dans le buffer		pthread_mutex_lock(&mutex2); //On lock		struct fractal *test = stack_pop(&buffer2); //On prend la fractale;		if (fractal_get_av(test) > fractal_get_av(bestAv)) { //Si la fractale est meilleure que celle précédement en mémoire			fractal_free(bestAv);			bestAv = test;		} else {			fractal_free(test);		}		pthread_mutex_unlock(&mutex2);		sem_post(&empty2);		/*   Update des variables pour la condition de fin   */		pthread_mutex_lock(&files);		pthread_mutex_lock(&newfract);		pthread_mutex_lock(&finished);		finishedFract++; //Une fracatle supplémentaire est terminée		flag = flagFiles;		nread = readFract;		nfinished = finishedFract;		pthread_mutex_unlock(&files);		pthread_mutex_unlock(&newfract);		pthread_mutex_unlock(&finished);	}	pthread_exit((void *) bestAv); //Renvoie la meilleure fractale}
开发者ID:SebStreb,项目名称:P2-Fractales,代码行数:40,


示例10: main

intmain(int  argc,     char **argv){    int        val;    my_stack_t int_stack;    stack_init(&int_stack, sizeof(int));    for(val = 0; val < 6; val++) {        stack_push(&int_stack, &val);    }    while (!is_stack_empty(&int_stack)) {        stack_pop(&int_stack, &val);        printf("This just popped: %d/n", val);    }    stack_destroy(&int_stack);    return 0;}
开发者ID:Jayaraj27,项目名称:workspace,代码行数:22,


示例11: dec2base

int  dec2base(int num, int base){ 	EntryType digit;  // 用于接收出栈操作返回的元素值	StackPtr ps;	   	stack_init(ps);    // 构造空栈		// 执行辗转相除操作,将余数入栈	while ( num){		stack_push(ps, num%base);		num = num / base; 	}		// 按由高位到低位的顺序输出八进制数	while ( !stack_empty(ps) ){		stack_pop(ps,  &digit);		printf(" %d", digit);	}		stack_destroy(ps);	return 0;}
开发者ID:NEWPLAN,项目名称:Sources,代码行数:22,


示例12: main

int main() {	char *data = NULL;	t_stack *stack = stack_init();		printf("Initial stack size: %d/n", stack->count);	// Push data in	stack_push(stack, "test");	stack_push(stack, "a");	stack_push(stack, "is");	stack_push(stack, "this");		printf("Full stack size: %d/n", stack->count);	// Show all of the data	while(stack->head != NULL) {		stack_pop(stack, (void**) &data);		printf("%s/n", data);	}	// Double check it is empty	printf("Empty stack size: %d/n", stack->count);	free(stack);	return 0;}
开发者ID:Coderlane,项目名称:TLibs,代码行数:22,


示例13: assert_convert_ldc_string

static void assert_convert_ldc_string(enum vm_type expected_type,                                      long long expected_value){    unsigned char code[] = { OPC_LDC, 0xff };    uint32_t cp_infos[NR_CP_ENTRIES];    uint8_t cp_types[NR_CP_ENTRIES];    struct expression *expr;    struct basic_block *bb;    const_set_int32_t(cp_infos, 0xff, 0x00);    cp_types[0xff] = CAFEBABE_CONSTANT_TAG_STRING;    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_value_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,代码行数:22,


示例14: process_rotate_general

int process_rotate_general(Stack s, int n, PROCESSOR_RESULT result) {	double theta, x, y;	StackItem *cur;	if (stack_size(s) < 2 * n + 1) {		return throw_error("Impossivel realizar opera
C++ stack_push函数代码示例
C++ stack_peek函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。