本文整理汇总了C++中pop函数的典型用法代码示例。如果您正苦于以下问题:C++ pop函数的具体用法?C++ pop怎么用?C++ pop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pdf_setGrayImageAsSoftMask
/* Set the passed DeviceGray image (which should be a PS style image
* dictionary) as a soft mask.
*/
Bool pdf_setGrayImageAsSoftMask(PDFCONTEXT *pdfc, OBJECT image)
{
Group *group = NULL ;
Bool result = FALSE ;
PDF_CHECK_MC(pdfc);
#define return DO_NOT_RETURN_-_SET_result_INSTEAD!
/* We need to save the current gstate before we install the DeviceGray color
space. */
if ( gs_gpush(GST_GROUP) ) {
int32 gid = gstackptr->gId ;
/* Set the colorspace to device gray and initialise the constant alpha. */
if ( gsc_setcolorspacedirect(gstateptr->colorInfo, GSC_FILL, SPACE_DeviceGray)) {
OBJECT gray = OBJECT_NOTVM_NAME(NAME_DeviceGray, LITERAL) ;
tsSetConstantAlpha(gsTranState(gstateptr), FALSE, 1, gstateptr->colorInfo);
/* Open a group to capture the image. */
if ( groupOpen(pdfc->corecontext->page, gray, TRUE /*I*/, FALSE /*K*/,
TRUE /*Banded*/, NULL /*bgcolor*/, NULL /*xferfn*/,
NULL /*patternTA*/, GroupLuminositySoftMask, &group)) {
if ( gs_gpush(GST_GSAVE) ) {
OBJECT psDict = OBJECT_NOTVM_NOTHING;
/* Copy the pdf dictionary into PostScript memory as we're calling a
PostScript function (we don't want to risk having a mixed pdf/ps
memory dictionary). */
if ( pdf_copyobject(NULL, &image, &psDict)) {
PDF_IMC_PARAMS* imc;
/* Get hold of the PDF stack. */
PDF_GET_IMC(imc);
/* Draw the image. */
if ( push(&psDict, &imc->pdfstack) ) {
if ( gs_image(pdfc->corecontext, &imc->pdfstack)) {
result = TRUE ;
} else {
pop(&imc->pdfstack) ;
}
}
} else /* Some routes through pdf_copyobject don't set errors. */
result = error_handler(VMERROR);
}
/* Close the group. */
if ( !groupClose(&group, result) )
result = FALSE ;
}
}
/* Restore gstate. */
if ( !gs_cleargstates(gid, GST_GROUP, NULL) )
result = FALSE;
/* Install the soft mask. */
if ( result )
result = tsSetSoftMask(gsTranState(gstateptr), LuminositySoftMask,
groupId(group), gstateptr->colorInfo);
}
#undef return
return result;
}
示例2: pop
uint8_t PinMock::next_digital_value(uint8_t pin) {
return pop(digital_values[pin]);
}
示例3: main
void main()
{
int ch;
clrscr();
while(ch!=3)
{
printf("\nEnter Your Choice: \n 1. For PUSH \n 2. For Pattern check \n 3. for Exit from the Window");
scanf("%d",&ch);
if(ch==1)
{
int n=0,s=0;
int f=1;
while(n!= -1 && f)
{
printf("Enter the no to Push\t for exit -1 ");
scanf("%d",&n);
if(stop== -1)
{
push(n);
s=n;
}
else
{
if( n == s+1 )
{
s=n;
push(n);
}
else
{
printf("Invalid PUSH %d ",n);
break;
}
}
}
}
else if(ch==2)
{
int i=0,temp=0,j=0,len;
char s[20];
printf("\n Enter the Pattern");
scanf("%s",s);
len=strlen(s);
while(i<len)
{
if(i==0)
{
for(j=0;j<= s[0]-'0' ;j++)
{
push(j);
}
temp=pop();
printf("\%d",temp);
temp=pop();
i++;
}
else
{
if(temp == s[i]-'0')
{
printf("\n%d",temp);
temp=pop();
i++;
}
else if(temp < s[i]-'0')
{
int c=0,k;
while(j<= s[i]-'0')
{
push(j);
j++;
c++;
}
for(k=0;k<c;k++)
{
if(temp!=-1)
{printf("\n%d",temp);}
temp=pop(); }
i++;
}
else
{ break; }
}
}
if(temp==-1)
{
printf("\nValid Pattern");
}
else
{
printf("\n Invalid Pattern %d",temp);
}
}
示例4: generateTree
tnode* generateTree(int s, char str[])
{
tnode* root = getNode(0,'o');
tnode* tmp;
queue* q = newQueue();
push(root, q);
int i,t = pow(2,s)-1;
for (i=0; i<t; i++)
{
tmp = pop(q);
int a = tmp->data;
char b = reverse(tmp->orand);
tmp->lchild = getNode(2*a+1,b);
tmp->lchild->parent = tmp;
push(tmp->lchild, q);
tmp->rchild = getNode(2*a+2,b);
tmp->rchild->parent = tmp;
push(tmp->rchild, q);
}
/*------NOW EVALUATING All NODES-------*/
t++;
int j=0;
for (i=0; i<t; i++)
{
tmp = pop(q);
if((tmp->data)%2 != 0)
{
tmp->data = evaluate(str,j,s);
// printf("--%d",tmp->data);
j++;
}
else
{
tmp->data = evaluate(str,j,s);
// printf("--%d",tmp->data);
j++;
push(tmp->parent, q);
}
}
while(!isEmpty(q))
{
tmp = pop(q);
if((tmp->data)%2 != 0 || tmp->data == 0)
{
if(tmp->orand == 'o')
tmp->data = max(tmp->lchild->data, tmp->rchild->data);
else
tmp->data = min(tmp->lchild->data, tmp->rchild->data);
}
else
{
if(tmp->orand == 'o')
tmp->data = max(tmp->lchild->data, tmp->rchild->data);
else
tmp->data = min(tmp->lchild->data, tmp->rchild->data);
push(tmp->parent, q);
}
}
return root;
}
示例5: SetEmpty
//把栈置空,先将各节点pop出去,内存释放,直到s = NULL。 若要将栈销毁,再free(s)即可。
//最简单的方法是s=NULL;但是没有释放有效节点,浪费内存。
void SetEmpty(PStack s)
{
while(s != NULL)
pop(s);
}
示例6: op
void
op(int what)
{
mnumber a, b, c, *spval;
char *lv;
int tp = type[what];
if (errflag)
return;
if (sp < 0) {
zerr("bad math expression: stack empty");
return;
}
if (tp & (OP_A2|OP_A2IR|OP_A2IO|OP_E2|OP_E2IO)) {
/* Make sure anyone seeing this message reports it. */
DPUTS(sp < 1, "BUG: math: not enough wallabies in outback.");
b = pop(0);
a = pop(what == EQ);
if (errflag)
return;
if (tp & (OP_A2IO|OP_E2IO)) {
/* coerce to integers */
if (a.type & MN_FLOAT) {
a.type = MN_INTEGER;
a.u.l = (zlong)a.u.d;
}
if (b.type & MN_FLOAT) {
b.type = MN_INTEGER;
b.u.l = (zlong)b.u.d;
}
} else if (a.type != b.type && what != COMMA &&
(a.type != MN_UNSET || what != EQ)) {
/*
* Different types, so coerce to float.
* It may happen during an assignment that the LHS
* variable is actually an integer, but there's still
* no harm in doing the arithmetic in floating point;
* the assignment will do the correct conversion.
* This way, if the parameter is actually a scalar, but
* used to contain an integer, we can write a float into it.
*/
if (a.type & MN_INTEGER) {
a.type = MN_FLOAT;
a.u.d = (double)a.u.l;
}
if (b.type & MN_INTEGER) {
b.type = MN_FLOAT;
b.u.d = (double)b.u.l;
}
}
if (noeval) {
c.type = MN_INTEGER;
c.u.l = 0;
} else {
/*
* type for operation: usually same as operands, but e.g.
* (a == b) returns int.
*/
c.type = (tp & OP_A2IR) ? MN_INTEGER : a.type;
switch(what) {
case AND:
case ANDEQ:
c.u.l = a.u.l & b.u.l;
break;
case XOR:
case XOREQ:
c.u.l = a.u.l ^ b.u.l;
break;
case OR:
case OREQ:
c.u.l = a.u.l | b.u.l;
break;
case MUL:
case MULEQ:
if (c.type == MN_FLOAT)
c.u.d = a.u.d * b.u.d;
else
c.u.l = a.u.l * b.u.l;
break;
case DIV:
case DIVEQ:
if (!notzero(b))
return;
if (c.type == MN_FLOAT)
c.u.d = a.u.d / b.u.d;
else
c.u.l = a.u.l / b.u.l;
break;
case MOD:
case MODEQ:
if (!notzero(b))
return;
c.u.l = a.u.l % b.u.l;
break;
case PLUS:
case PLUSEQ:
//.........这里部分代码省略.........
示例7: notation
/* infix_to_postfix:
routine that will be called with parameter:
char *in characters of infix notation (algebraic formula)
returns: char * pointer to string of returned postfix */
static char *
infix_to_postfix( char *infix ) {
INTDBG("ENTER: in: %s, size: %zu\n", infix, strlen(infix));
static char postfix[2*PAPI_HUGE_STR_LEN]; // output
unsigned int index;
int postfixlen;
char token;
if ( strlen(infix) > PAPI_HUGE_STR_LEN )
PAPIERROR("A infix string (probably in user-defined presets) is too big (max allowed %d): %s", PAPI_HUGE_STR_LEN, infix );
// initialize stack
memset( &stack, 0, 2*PAPI_HUGE_STR_LEN );
stacktop = -1;
push('#');
/* initialize output string */
memset(&postfix,0,2*PAPI_HUGE_STR_LEN);
postfixlen = 0;
for( index=0; index<strlen(infix); index++ ) {
token = infix[index];
INTDBG("INTDBG: in: %s, length: %zu, index: %d token %c\n", infix, strlen( infix ), index, token);
switch( token ) {
case '(':
push( token );
break;
case ')':
if (postfix[postfixlen-1]!='|') postfix[postfixlen++] = '|';
while ( stack[stacktop] != '(' ) {
postfix[postfixlen++] = pop();
postfix[postfixlen++] = '|';
}
token = pop(); /* pop the '(' character */
break;
case '+':
case '-':
case '*':
case '/':
case '%':
case '^': /* if an operator */
if (postfix[postfixlen-1]!='|') postfix[postfixlen++] = '|';
while ( priority(stack[stacktop]) > priority(token) ) {
postfix[postfixlen++] = pop();
postfix[postfixlen++] = '|';
}
push( token ); /* save current operator */
break;
default: // if alphanumeric character which is not parenthesis or an operator
postfix[postfixlen++] = token;
break;
} // end switch symbol
} // end while
/* Write any remaining operators */
if (postfix[postfixlen-1]!='|') postfix[postfixlen++] = '|';
while ( stacktop>0 ) {
postfix[postfixlen++] = pop();
postfix[postfixlen++] = '|';
}
postfix[postfixlen++] = '\0';
stacktop = -1;
INTDBG("EXIT: postfix: %s, size: %zu\n", postfix, strlen(postfix));
return (postfix);
} // end infix_to_postfix
示例8: do_assemble2
//.........这里部分代码省略.........
nextpc = pc + ist.name[3] - 1;
}
}
else if (iname == 35) {
if (freg[ist.name[1]] > freg[ist.name[2]]) {
nextpc = pc + ist.name[3] - 1;
}
}
else if (iname == 36) {
if (freg[ist.name[1]] < freg[ist.name[2]]) {
nextpc = pc + ist.name[3] - 1;
}
}
else if (iname == 37) {
if (freg[ist.name[1]] >= freg[ist.name[2]]) {
nextpc = pc + ist.name[3] - 1;
}
}
else if (iname == 38) {
if (freg[ist.name[1]] <= freg[ist.name[2]]) {
nextpc = pc + ist.name[3] - 1;
}
}
/*JUMP命令 */
else if (iname == 39) {
if (ist.name[1] == -100) {
freg[2] = atanf(freg[2]);
nextpc = pop(&call_stack) - 1;
} else if (ist.name[1] == -200) {
freg[2] = sqrtf(freg[2]);
nextpc = pop(&call_stack) - 1;
} else if (ist.name[1] == -300) {
regist[4] = read_int();
printf("read_int: %d\n", regist[4]);
nextpc = pop(&call_stack) - 1;
} else if (ist.name[1] == -400) {
freg[2] = read_float();
printf("read_float: %f\n", freg[2]);
nextpc = pop(&call_stack) - 1;
} else if (ist.name[1] == -500) {
printf("aaa\n");
if(ppp < freg[2])
{
ppp = freg[2];
}
if(nnn > freg[2])
{
nnn = freg[2];
}
//print_register();
nextpc = label_trans(program->insts[pc].name[1], program) - 1;
//freg[2] = sinf(freg[2]);
//printf("read_float: %f\n", freg[2]);
//nextpc = pop(&call_stack) - 1;
} else if (ist.name[1] == -600) {
freg[2] = cosf(freg[2]);
//printf("read_float: %f\n", freg[2]);
nextpc = pop(&call_stack) - 1;
} else if (ist.name[1] == -700) {
//print_int
示例9: do_assemble
//.........这里部分代码省略.........
else if (strcmp(iname, "jump") == 0) {
nextpc = label_trans(ist.name[1], program) - 1;
++cnt[40];
}
else if (strcmp(iname, "call") == 0) {
nextpc = label_trans(ist.name[1], program) - 1;
++cnt[41];
/*
if (strncmp(ist.name[1], "L_sin", 5) == 0) {
//printf("%f\n", freg[2]);
freg[2] = sinf(freg[2]);
nextpc = pc;
} else if (strncmp(ist.name[1], "L_cos", 5) == 0) {
//printf("%f\n", freg[2]);
freg[2] = cosf(freg[2]);
nextpc = pc;
*/
/*} else */ if (strncmp(ist.name[1], "L_atan", 6) == 0) {
//printf("%f\n", freg[2]);
freg[2] = atanf(freg[2]);
nextpc = pc;
} else if (strncmp(ist.name[1], "L_sqrt", 6) == 0) {
//printf("%f\n", freg[2]);
freg[2] = sqrtf(freg[2]);
nextpc = pc;
} else if (strcmp(ist.name[1], "min_caml_read_int") == 0) {
regist[4] = read_int();
//printf("read_int: %d\n", regist[4]);
nextpc = pc;
} else if (strcmp(ist.name[1], "min_caml_read_float") == 0) {
freg[2] = read_float();
//printf("read_float: %f\n", freg[2]);
nextpc = pc;
} else {
push(&call_stack, (pc + 1));
}
}
else if (strcmp(iname, "return") == 0) {
nextpc = pop(&call_stack) - 1;
}
//命令が存在しなかった場合error
else {
printf("Error:this is legal instruction!:%s\n",
program->insts[pc].name[0]);
exit(1);
}
//printf("%d\n", regist[3]);
nextpc++;
/*
if(count > 817757)
{
for(j = 0; j < program->label_count; ++j)
{
if(program->labels[j]->index == pc)
{
printf("%s:\n", program->labels[j]->name);
}
}
printf("%d", pc);
print_instruction(ist);
// printf("%d\n", count);
printf("%d\n", memory[4062].i);
print_register();
} */
/*
if((count % 1000000) == 0)
{
printf("%d\n", count);
}
*/
/*命令がラストの行まで行けば処理を終了する */
if (nextpc >= program->inst_count) {
break;
}
}
for (i = 0; i < 100; ++i) {
printf("%d: %d\n", i, cnt[i]);
}
return 0;
}
示例10: segmentImage
int segmentImage(frame_t *frame, frame_t *res, int *largestLabel) {
//segment the image (label each connected component a different label)
if (thresholdImage(frame, res) != 0) {
printf("segmentImage: thresholdImage failure code\n");
return 1;
}
// Segmentation code here - watershed
// START LABELS AT 2 (non-labeled remains at 0)
int i, j, pValW, pValH, label = 2;
int rWidth = res->image->width;
int rHeight = res->image->height;
pixel_t *P;
int x, y;
createStack();
for (i = 0; i < rHeight; i++) {
for (j = 0; j < rWidth; j++) {
pValH = i;
pValW = j;
// Using pVal, we'll segment surrounding pixels with the same label.
if (res->image->data[pValH*rWidth + pValW].L == 0) {
// Pixel did not have a value
//LOG_ERR("segmentImage: Continuing with seeds, pixel off at (w,h) -> (%d, %d)\n", pValW, pValH);
} else if (res->image->data[pValH*rWidth + pValW].L > 1) {
//LOG_ERR("segmentImage: Continuing with seeds, pixel already labeled at (w,h) -> (%d, %d)\n", pValW, pValH);
} else {
LOG_ERR("segmentImage: Labeling connected pixels starting at (w,h) -> (%d, %d)\n", pValW, pValH);
// Add pixels to stack
push(&res->image->data[pValH * rWidth + pValW], pValW, pValH);
while(isEmpty() != 0) {
P = pop(&x, &y);
if (P->L == 1) {
P->L = label;
// Add neighboring pixels within the bounds to the stack
if (y-1 >= 0) {
if(res->image->data[(y-1)*rWidth+x].L == 1){
push(&res->image->data[(y-1)*rWidth+x], x, y-1);
}
}
if (y+1 < rHeight) {
if (res->image->data[(y+1)*rWidth+x].L == 1) {
push(&res->image->data[(y+1)*rWidth+x], x, y+1);
}
}
if (x-1 >= 0) {
if(res->image->data[y*rWidth+(x-1)].L == 1) {
push(&res->image->data[y*rWidth+(x-1)], x-1, y);
}
}
if (x+1 < rWidth) {
if(res->image->data[y*rWidth+(x+1)].L == 1) {
push(&res->image->data[y*rWidth+(x+1)], x+1, y);
}
}
}
}
}
label++;
}
}
// Other method of labelling pixels - sequential algo
#if 0
// segment remaining pixels by looking for neighbor nearby or creating new label
int val1, val2, val3, val4;
for (i = 0; i <rHeight; i++){
for (j = 0; j < rWidth; j++) {
val1 = 0;
val2 = 0;
val3 = 0;
val4 = 0;
// pixel has not been labelled yet
if (res->image->data[i*rWidth+j].L == 1) {
// give the current pixel the label of its neighbor or new label
if (i-1 >= 0)
val1 = res->image->data[(i-1)*rWidth+j].L;
if (i+1 < rHeight)
val2 = res->image->data[(i+1)*rWidth+j].L;
if (j-1 >= 0)
val3 = res->image->data[i*rWidth+(j-1)].L;
if (j+1 < rWidth)
val4 = res->image->data[i*rWidth+(j+1)].L;
if (val1 > 1){
res->image->data[i*rWidth+j].L = val1;
} else if (val2 > 1) {
res->image->data[i*rWidth+j].L = val2;
} else if (val3 > 1) {
res->image->data[i*rWidth+j].L = val3;
} else if (val4 > 1) {
res->image->data[i*rWidth+j].L = val4;
} else {
res->image->data[i*rWidth+j].L = label;
label++;
}
}
}
}
#endif
//.........这里部分代码省略.........
示例11: while
void Stack_Node::makeEmpty()
{
while (!isEmpty())
pop();
}
示例12: test_to_push_and_pop_together
void test_to_push_and_pop_together(){
int value = 2;
stack=create(2);
ASSERT(push(stack, &value));
ASSERT(&value == pop(stack));
}
示例13: test_to_pop_from_an_empty_stack
void test_to_pop_from_an_empty_stack(){
stack=create(2);
ASSERT(false==pop(stack));
}
示例14: pc
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
// rbx,: methodOop
// rcx: scratrch
// r13: sender sp
if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
address entry_point = __ pc();
// These don't need a safepoint check because they aren't virtually
// callable. We won't enter these intrinsics from compiled code.
// If in the future we added an intrinsic which was virtually callable
// we'd have to worry about how to safepoint so that this code is used.
// mathematical functions inlined by compiler
// (interpreter must provide identical implementation
// in order to avoid monotonicity bugs when switching
// from interpreter to compiler in the middle of some
// computation)
//
// stack: [ ret adr ] <-- rsp
// [ lo(arg) ]
// [ hi(arg) ]
//
// Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
// native methods. Interpreter::method_kind(...) does a check for
// native methods first before checking for intrinsic methods and
// thus will never select this entry point. Make sure it is not
// called accidentally since the SharedRuntime entry points will
// not work for JDK 1.2.
//
// We no longer need to check for JDK 1.2 since it's EOL'ed.
// The following check existed in pre 1.6 implementation,
// if (Universe::is_jdk12x_version()) {
// __ should_not_reach_here();
// }
// Universe::is_jdk12x_version() always returns false since
// the JDK version is not yet determined when this method is called.
// This method is called during interpreter_init() whereas
// JDK version is only determined when universe2_init() is called.
// Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
// java methods. Interpreter::method_kind(...) will select
// this entry point for the corresponding methods in JDK 1.3.
// get argument
if (kind == Interpreter::java_lang_math_sqrt) {
__ sqrtsd(xmm0, Address(rsp, wordSize));
} else {
__ fld_d(Address(rsp, wordSize));
switch (kind) {
case Interpreter::java_lang_math_sin :
__ trigfunc('s');
break;
case Interpreter::java_lang_math_cos :
__ trigfunc('c');
break;
case Interpreter::java_lang_math_tan :
__ trigfunc('t');
break;
case Interpreter::java_lang_math_abs:
__ fabs();
break;
case Interpreter::java_lang_math_log:
__ flog();
break;
case Interpreter::java_lang_math_log10:
__ flog10();
break;
default :
ShouldNotReachHere();
}
// return double result in xmm0 for interpreter and compilers.
__ subptr(rsp, 2*wordSize);
// Round to 64bit precision
__ fstp_d(Address(rsp, 0));
__ movdbl(xmm0, Address(rsp, 0));
__ addptr(rsp, 2*wordSize);
}
__ pop(rax);
__ mov(rsp, r13);
__ jmp(rax);
return entry_point;
}
示例15: undefine
static void undefine(node s){
assertpos(issym(s),s);
/* if (debug) fprintf(stderr,"undefining %s\n",tostring(s)); */
pop(s->body.symbol.name->body.unique_string.symbol_list);
}