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


C++ pop_stack函数代码示例

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


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

示例1: main

int main()
{
	int n;
	stack tmp = { 0, 0 };
	stack *s = &tmp;
	init_stack(s);
	printf("input int:");
	while (scanf("%d", &n) != EOF) {
		if (n < 0) {
			int v = pop_stack(s);
			printf("pop() -> v:%d,num:%d,size:%d\n", v,
			       get_stack_datanum(s), get_stack_size(s));
		} else if (n > 0) {
			push_stack(s, n);
			printf("push() -> num:%d,size:%d\n",
			       get_stack_datanum(s), get_stack_size(s));
		} else {
			break;
		}
		printf("input int:");
	}
	printf("over...\n");
	release_stack(s);	//释放内存
	return 0;
}
开发者ID:wangyeweikuer,项目名称:algorithms,代码行数:25,代码来源:test_array_stack.c

示例2: filter_arr

/* EFUN: filter (array part)
   
   Runs all elements of an array through fun
   and returns an array holding those elements that fun
   returned 1 for.
   */
struct vector *
filter_arr(struct vector *p, struct closure *fun)
{
    struct vector *r;
    char *flags;
    int cnt,res;
    
    if (p->size<1)
	return allocate_array(0);

    res = 0;
    flags = tmpalloc((size_t)p->size + 1); 
    for (cnt = 0; cnt < p->size; cnt++) {
	push_svalue(&p->item[cnt]);
	(void)call_var(1, fun);
	if (sp->type == T_NUMBER && sp->u.number) {
	    flags[cnt] = 1; 
	    res++; 
	} else
	    flags[cnt] = 0;
	pop_stack();
    }
    r = allocate_array(res);
    for (cnt = res = 0; res < r->size && cnt < p->size; cnt++) {
	if (flags[cnt]) 
	    assign_svalue_no_free(&r->item[res++], &p->item[cnt]);
    }
/*    tmpfree(flags); */
    return r;
}
开发者ID:DruSatori,项目名称:AEMud,代码行数:36,代码来源:array.c

示例3: php_roxen_low_ub_write

static int
php_roxen_low_ub_write(const char *str, uint str_length) {
  int sent_bytes = 0;
  struct pike_string *to_write = NULL;
#ifdef ZTS
  PLS_FETCH();
#endif
#ifdef ROXEN_USE_ZTS
  GET_THIS();
#endif
  if(!MY_FD_OBJ->prog) {
    PG(connection_status) = PHP_CONNECTION_ABORTED;
    zend_bailout();
    return -1;
  }
  to_write = make_shared_binary_string(str, str_length);
  push_string(to_write);
  safe_apply(MY_FD_OBJ, "write", 1);
  if(Pike_sp[-1].type == PIKE_T_INT)
    sent_bytes = Pike_sp[-1].u.integer;
  pop_stack();
  if(sent_bytes != str_length) {
    /* This means the connection is closed. Dead. Gone. *sniff*  */
    php_handle_aborted_connection();
  }
  return sent_bytes;
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:27,代码来源:roxen.c

示例4: pop_stack

/* virtual */ void CollisionShapeNodeVisitor::visit(CollisionShapeNode* node) {

  pop_stack(node);
  math::mat4 curr_matrix(matrix_stack_.top() * node->get_transform());

  if (shape_index_ >= rigid_body_->shapes().size()) {
    rigid_body_->shapes().push_back(RigidBodyNode::ShapeElement());
    resync_ = true;
  }
  RigidBodyNode::ShapeElement& sh = rigid_body_->shapes().at(shape_index_);
  if (sh.transform != curr_matrix) {
    sh.transform = curr_matrix;
    resync_ = true;
  }
  if (sh.shape_name != node->data.get_shape()) {
    sh.shape =
        CollisionShapeDatabase::instance()->lookup(node->data.get_shape());
    sh.shape_name = node->data.get_shape();
    resync_ = true;
  }
  ++shape_index_;

  // visit children of the collision shape
  if (node->has_children()) {
    push_stack(curr_matrix);

    for (auto child : node->children_)
      child->accept(*this);
  }
}
开发者ID:MariyaKaisheva,项目名称:guacamole,代码行数:30,代码来源:CollisionShapeNodeVisitor.cpp

示例5: release_stack

void release_stack(struct node* p_top)
{
	while(is_empty(p_top) == NON_EMPTY)
	{
		pop_stack(p_top);
	}
}
开发者ID:jasonleaster,项目名称:Algorithm,代码行数:7,代码来源:release_stack.c

示例6: pextsFatalError

static void pextsFatalError(void *ctx, const char *msg, ...)
{
  char    *vmsg;
  va_list  ap;
  
  DBG_FUNC_ENTER();
  if (CB_ABSENT(fatalErrorSAX)) {
    DBG_FUNC_LEAVE();
    return;
  }

  THIS->ctxt = (xmlParserCtxtPtr)ctx;
  
  push_object(this_object());
  /* I'm being lazy here :> */
  vmsg = NULL;
  va_start(ap, msg);
  if (vasprintf(&vmsg, msg, ap) < -1)
    push_int(0);
  else {
    push_text(vmsg);
    free(vmsg);
  }
  push_svalue(&THIS->user_data);
  CB_CALL(fatalErrorSAX, 3);
  pop_stack();
  
  DBG_FUNC_LEAVE();
}
开发者ID:ajinkya007,项目名称:societyserver,代码行数:29,代码来源:xml_sax.c

示例7: pipe_read_input_callback

static void pipe_read_input_callback(INT32 args)
{
  struct input *i;
  struct pike_string *s;

  if (args<2 || sp[1-args].type!=T_STRING)
    Pike_error("Illegal argument to pipe->read_input_callback\n");
   
  i=THIS->firstinput;

  if (!i)
    Pike_error("Pipe read callback without any inputs left.\n");

  s=sp[1-args].u.string;

  if(append_buffer(s))
  {
    /* THIS DOES NOT WORK */
    push_int(0);
    push_int(0);
    push_callback(offset_input_close_callback);
    apply_low(i->u.obj,i->set_nonblocking_offset,3);
    pop_stack();
    THIS->sleeping=1;
  }

  low_start();
  pop_n_elems(args-1);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:29,代码来源:pipe.c

示例8: f_db_fetch

void f_db_fetch (void)
{
	db_t *db;
	array_t *ret;

	valid_database("fetch", &the_null_array);

	db = find_db_conn((sp-1)->u.number);
	if (!db) {
		error("Attempt to fetch from an invalid database handle\n");
	}

	if (db->type->fetch) {
		ret = db->type->fetch(&(db->c), sp->u.number);
	} else {
		ret = &the_null_array;
	}

	pop_stack();
	if (!ret) {
		if (db->type->error) {
			char *errormsg;

			errormsg = db->type->error(&(db->c));
			put_malloced_string(errormsg);
		} else {
			sp->u.number = 0;
		}
	} else {
		put_array(ret);
	}
}
开发者ID:BPotato,项目名称:fluffos,代码行数:32,代码来源:db.c

示例9: do_clear

void do_clear (stack *stack) {
   DEBUGF ('m', "stack=%p\n", stack);
   while (! empty_stack (stack)) {
      bigint *bigint = pop_stack (stack);
      free_bigint (bigint);
   }
}
开发者ID:zero14777,项目名称:My-Stuff,代码行数:7,代码来源:main.c

示例10: pextsElementDecl

static void pextsElementDecl(void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
{
  struct mapping  *cmap;
  
  DBG_FUNC_ENTER();
  if (CB_ABSENT(elementDeclSAX)) {
    DBG_FUNC_LEAVE();
    return;
  }

  THIS->ctxt = (xmlParserCtxtPtr)ctx;
  
  push_object(this_object());
  safe_push_text(name);
  push_int(type);
  cmap = tree2mapping(content);
  if (cmap)
    push_mapping(cmap);
  else
    push_int(0);
  push_svalue(&THIS->user_data);
  
  CB_CALL(elementDeclSAX, 5);
  pop_stack();
  
  DBG_FUNC_LEAVE();
}
开发者ID:ajinkya007,项目名称:societyserver,代码行数:27,代码来源:xml_sax.c

示例11: f_crypt

void
f_crypt (void)
{
    const char *res, *p;
    char salt[SALT_LEN + 1];
    const char *choice =
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./";

    if (sp->type == T_STRING && SVALUE_STRLEN(sp) >= 2) {
        p = sp->u.string;
    } else {
        int i;
        
        for (i = 0; i < SALT_LEN; i++)
            salt[i] = choice[random_number(strlen(choice))];

        salt[SALT_LEN] = 0;
        p = salt;
    }
    
    res = string_copy(CRYPT((sp-1)->u.string, p), "f_crypt");
    pop_stack();
    free_string_svalue(sp);
    sp->subtype = STRING_MALLOC;
    sp->u.string = res;
}
开发者ID:Yuffster,项目名称:fluffOS,代码行数:26,代码来源:efuns_port.c

示例12: f_bson_buf_find

void f_bson_buf_find(void){
	int size;
	bson b[1];
	bson  sub;
	svalue_t v;
	bson_iterator it;

	size = (sp-1)->u.buf->size;
	bson_init_empty(b);
	bson_init_size( b, size );
	memcpy(b->data, (sp-1)->u.buf->item, size);
	b->finished = 1;

	/* buff不合法 */
	if(bson_size(b) != size){
		pop_n_elems(st_num_arg);
		push_number(0);
		goto free_bson;
	}
	/* 找不到数据 */
	if(!bson_find( &it, b, sp->u.string )){
		pop_n_elems(st_num_arg);
		push_number(0);
		goto free_bson;
	}
	bson_to_v(&it, &v);
	free_buffer((sp-1)->u.buf);
	pop_stack();
	*sp = v;
free_bson:
	bson_destroy( b );
}
开发者ID:carriercomm,项目名称:mudos-1,代码行数:32,代码来源:mg.c

示例13: f_tokenize

static void f_tokenize( INT32 args )
{
    if( !args || Pike_sp[-args].type != PIKE_T_STRING )
        Pike_error("Illegal argument 1 to tokenize\n");
    tokenize( Pike_sp[-args].u.string );
    stack_swap();
    pop_stack();
}
开发者ID:johan,项目名称:pike,代码行数:8,代码来源:rcs.c

示例14: jj_expressao_5

// X5:	consulta (pilha de operadores, Y);
//		Se Y != "(": executa GERACÓDIGO, detalhada adiante;. GO TO X5.
//		Se Y =	"(":	desempilha (pilha de operadores, Y);
void jj_expressao_5() {
	if (strcmp(consulta_pilha(pilha_operadores), "(") != 0) {
		jj_gera_codigo();
		jj_expressao_5();
	} else {
		pop_stack(&pilha_operadores);
	}
}
开发者ID:barbolo,项目名称:educational_compiler,代码行数:11,代码来源:actions.c

示例15: dispose_stack

int dispose_stack(stack* s, void (*ufree)(void*)) {
	void* data;
	while ((data = pop_stack(s)) != NULL) {
		ufree(data);
	}
	free(s);
	return 1;
}
开发者ID:crypt5,项目名称:Utilities,代码行数:8,代码来源:stack.c


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