• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ pop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了pop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:69,代码来源:pdfgs4.c


示例2: pop

uint8_t PinMock::next_digital_value(uint8_t pin) {
  return pop(digital_values[pin]);
}
开发者ID:johntrimble,项目名称:JTIncrementalEncoder,代码行数:3,代码来源:Arduino.cpp


示例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);

			}
		}
开发者ID:dilkhush57,项目名称:FlightNetworkPlacement_Dilkhush-Sohanlal-Soni,代码行数:97,代码来源:FM1.C


示例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;
}
开发者ID:mayankgrwl97,项目名称:Competitive-Coding,代码行数:67,代码来源:lab3.c


示例5: SetEmpty

//把栈置空,先将各节点pop出去,内存释放,直到s = NULL。 若要将栈销毁,再free(s)即可。
//最简单的方法是s=NULL;但是没有释放有效节点,浪费内存。
void SetEmpty(PStack s)
{
    while(s != NULL)
        pop(s);
}
开发者ID:canonxu,项目名称:DataStructureAndAlgorithm,代码行数:7,代码来源:stack_by_linklist.c


示例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:
//.........这里部分代码省略.........
开发者ID:SumiTomohiko,项目名称:rush,代码行数:101,代码来源:math.c


示例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
开发者ID:QuantScientist3,项目名称:pbdPAPI,代码行数:68,代码来源:papi_preset.c


示例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
开发者ID:pandora2000,项目名称:aiueo,代码行数:67,代码来源:simoo.c


示例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;
}
开发者ID:pandora2000,项目名称:aiueo,代码行数:101,代码来源:simoo.c


示例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
//.........这里部分代码省略.........
开发者ID:sarahttan,项目名称:CUDAPeopleCounter,代码行数:101,代码来源:peopleCounter-v1.c


示例11: while

void Stack_Node::makeEmpty()
{
	while (!isEmpty())
		pop();
}
开发者ID:jayjihun,项目名称:DataStructureStudy,代码行数:5,代码来源:Stack.cpp


示例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));
}
开发者ID:jainsahab,项目名称:DSA,代码行数:6,代码来源:stack_libTest.c


示例13: test_to_pop_from_an_empty_stack

void test_to_pop_from_an_empty_stack(){
	stack=create(2);
	ASSERT(false==pop(stack));
}
开发者ID:jainsahab,项目名称:DSA,代码行数:4,代码来源:stack_libTest.c


示例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;
}
开发者ID:ericbbcc,项目名称:hotspot,代码行数:90,代码来源:interpreter_x86_64.cpp


示例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);
     }
开发者ID:garyfurnish,项目名称:M2,代码行数:5,代码来源:dictionary.c


示例16: main

int main() {

  char input[101]; // max input is 100 plus 1 for '\0' char
  bool done = false;

  initStack();

  while (!done) {
    // the "%100s" tells scanf we want no more than 100 chars
    if (scanf("%100s", input) == EOF) {
      // End of input, assume the user wants to exit
      done = true;
    } else if (isnumber(input)) {
      // push number on stack
      push(atoi(input));
    } else if (strcmp(input, "+") == 0) {
      // integer add
      if (length() < 2) {
        smallStackError(input);
      } else {
        push(pop() + pop());
      }
    } else if (strcmp(input, "-") == 0) {
      // integer subtract
      if (length() < 2) {
        smallStackError(input);
      } else {
        // subtract is non-commutative so we can't inline the pops
        int a = pop();
        int b = pop();
        push(b - a);
      }
    } else if (strcmp(input, "*") == 0) {
      // integer multiply
      if (length() < 2) {
        smallStackError(input);
      } else {
        push(pop() | pop());
      }
    } else if (strcmp(input, "/") == 0) {
      // integer divide
      if (length() < 2) {
        smallStackError(input);
      } else {
        // divide is non-commutative so we can't inline the pops
        int a = pop();
        int b = pop();
        if (a == 0) {
          printf("Ignoring illegal division by zero\n");
          push(b);
          push(a);
        } else {
          push(b / a);
        }
      }
    } else if (strcmp(input, "|") == 0) {
      // bitwise or
      if (length() < 2) {
        smallStackError(input);
      } else {
        push(pop() | pop());
      }
    } else if (strcmp(input, "p") == 0) {
      // print whole stack
      printStack(false);
      printStack(true);
      printf("\n");
    } else if (strcmp(input, "t") == 0) {
      // print top of stack
      if (length() < 1) {
        smallStackError(input);
      } else {
        printf("%d\n", peek());
      }
    } else if (strcmp(input, "w") == 0) {
      // wipe stack
      while (!isEmpty()) {
        pop();
      }
    } else if (strcmp(input, "q") == 0) {
      // quit
      done = true;
    } else {
      printf("Ignoring unknown command: %s\n", input);
    }
  }

  return 0;
}
开发者ID:grpatter,项目名称:iu_cs_jegm,代码行数:89,代码来源:stupidCalculator.c


示例17: main

int main()
{
	int i,j,flag,curr,count,n;
	int **arr;
	FILE *ptr;
	top=-1;
	ptr=fopen("diji.txt","r");
	fscanf(ptr,"%d",&n);
	arr=(int**)malloc(sizeof(int)*n*n);
	for(i=0;i<n;i++)
		*(arr+i)=(int*)malloc(sizeof(int)*n);
		
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			{
				fscanf(ptr,"%d",&arr[i][j]);
			}
	}
	fclose(ptr);
	//disp
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			printf("%d   ",arr[i][j]);
		printf("\n");	
	}
	count=0;	
	printf("\nenter the source::\t");
	scanf("%d",&curr);
	curr--;
	while(1)
	{	flag=0;
		push(curr);
		printf("%c",65+curr);
		for(i=0;i<n;i++)
					arr[i][curr]=0;
		for(i=0;i<n;i++)
		{
				if(arr[curr][i]>0)
				{
					flag=1;
					break;
				}
		}
		if(flag==0)
		{
			pop();
			if(top==-1)
				exit(1);
			else
			{
				curr=stack[top];
				count++;
			}
		}
		else
		{
			curr=i;
			count++;
		}
		if(count==n)
			exit(1);
		if(count==n*n)
					exit(1);
	}
	return 0;	
}
开发者ID:sara-02,项目名称:code_dump,代码行数:68,代码来源:dfs.c


示例18: merge

void merge(struct node *root1,struct node *root2)
{

  //Initializing
  struct snode *s1 = NULL;
  struct node *current1 = root1;

  struct snode *s2 = NULL;
  struct node *current2 = root2;


  //Base cases
  if(root1==NULL)
  {
    inorder(root2);
    return;
  }

  if(root2==NULL)
  {
    inorder(root1);
    return;
  }

  while(current1!= NULL || !isEmpty(s1) || current2!=NULL || !isEmpty(s2))
  {

    if(current1!=NULL || current2!=NULL)
    {
      if(current1!=NULL)
      {

        push(&s1,current1);
        current1 = current1->left;

      }

      if(current2!=NULL)
      {

        push(&s2,current2);
        current2 = current2->left;

      }
    }

    else {

      if(isEmpty(s1))
      {
        while(!isEmpty(s2))
        {
          current2 = pop(&s2);
          current2->left = NULL;
          inorder(current2);


        }
        return;
      }
      if(isEmpty(s2))
      {

        while(!isEmpty(s1))
        {
          current1 = pop(&s1);
          current1->left = NULL;
          inorder(current1);

        }
        return;


      }

      current1 = pop(&s1);
      current2 = pop(&s2);

      if(current1->data < current2->data)
      {
          printf("%d ",current1->data);
          current1=current1->right;
          push(&s2,current2);
          current2= NULL;

      }
      else {
        printf("%d ",current2->data);
          current2=current2->right;
          push(&s1,current1);
          current1= NULL;

      }

      }

    }

  }
开发者ID:batraman,项目名称:sandbox,代码行数:99,代码来源:MergeBalancedBSTLimitedSpace.c


示例19: main

/*注意输入的时候,需要用空格作为间断*/
main()
{
    int type;
    double temp; /*储存弹出的临时数据*/
    char s[MAXOP];
    printf("----------RPN calculator----------\n");
    printf("*      use ctrl+z to exit        *\n");
    printf("*      use space to split        *\n");
    printf("----------------------------------\n");
    printf("please input:");

    while((type=getop(s))!=EOF)
    {
        switch (type)
        {
        case NUMBER:
            push(atof(s));
            break;
        case '+':
            push(pop()+pop());
            break;
        case '*':
            push(pop()*pop());
            break;
        case '-':
            temp=pop();
            push(pop()-temp);
            break;
        case '/':
            temp=pop();
            if(temp!=0.0)
                push(pop()/temp);
            else
                printf("error:zero divisor\n");
            break;
        case '%':/*求模运算*/
            temp=pop();
            if(temp!=0.0)
                push(fmod(pop(),temp));
            else
                printf("error:zero divisor\n");
            break;
        case '\n':
            printf("result:\t%.8g\n",pop());
            break;
        default:
            printf("error:unknown command %s\n",s);
            break;
        }
    }
    return 0;
}
开发者ID:hanxiaomax,项目名称:KRC_exercise,代码行数:53,代码来源:cp4-3.c


示例20: traverse_km_tree

/**
 * \brief Traverses the tree and calls t_coffee to produce the alignments
 * \param root The root of the tree.
 * \param vecs The vector set.
 * \param seq_set The sequence set.
 * \param out_f The output file.
 * \param n_core The number of cores to use (OPEN-MP for kmeans/fork in T-Coffee)
 * \param gapopen The gapopening costs
 * \param gapext The gapextension costs
 * \param method The method to use in the alignment
 */
void
traverse_km_tree(KM_node* root, int *vecs, const SeqSet *seq_set, char *out_f, int n_cores, int gapopen, int gapext, char *method)
{
	Stack *to_do =Stack_init();
	Node_pair *tmp = (Node_pair*)my_malloc(sizeof(Node_pair));
	tmp->node=root;
	tmp->id = 0;
	push(to_do, tmp);

	KM_node* current;
	size_t child;
	size_t j;
// 	size_t pos;
	char command[1000];
	while (to_do->size != 0)
	{

		current = ((Node_pair*)to_do->last)->node;
		child = ((Node_pair*)to_do->last)->id;
		if (current->n_children==0)
		{
			if(current->end-current->start > 2)
			{
				sprintf(command, "%li",current->id);
				write_files(current, vecs, seq_set, command);
// 				sprintf(command,"clustalo --guidetree-out co_tree.dnd -i %li --force >/dev/null 2>/dev/null", current->id);
// 				if (system(command))
// 				{
// 					printf("%s\n",command);
// 					exit(1);
// 				}
				if (current->id!=0)
					sprintf(command,"t_coffee -in %li -output fasta_aln -outfile %li.fa -n_core %i -gapopen %i -gapext %i -method %s -quiet >/dev/null 2>/dev/null", current->id, current->id, n_cores, gapopen, gapext, method);
				else
					sprintf(command,"t_coffee -in %li -output fasta_aln -outfile %s -n_core %i -gapopen %i -gapext %i -method %s -quiet >/dev/null 2>/dev/null ",  current->id, out_f, n_cores, gapopen, gapext, method);
				if (system(command))
				{
					printf("ERROR when running: %s\n",command);
					exit(1);
				}
			}
			else
				if(current->end-current->start > 1)
			{
				sprintf(command, "%li",current->id);
				write_files(current, vecs, seq_set, command);
				if (current->id!=0)
					sprintf(command,"t_coffee -in %li -output fasta_aln -outfile %li.fa -n_core %i -gapopen %i -gapext %i -method %s -quiet >/dev/null 2>/dev/null", current->id, current->id, n_cores, gapopen, gapext, method);
				else
					sprintf(command,"t_coffee -in %li -output fasta_aln -outfile %s -n_core %i -gapopen %i -gapext %i -method %s -quiet >/dev/null 2>/dev/null ",  current->id, out_f, n_cores, gapopen, gapext, method);

				printf("%s\n", command);
				if (system(command))
				{
					printf("ERROR when running: %s\n",command);
					exit(1);
				}
			}
			else
			{
				sprintf(command, "%li.fa",current->id);
				write_files(current, vecs, seq_set, command);
			}
			tmp =(Node_pair*) pop(to_do);
		}
		else
		{
			if (child == current->n_children)
			{
				if (current->id!=0)
					sprintf(command, "t_coffee -output fasta_aln -method %s -quiet -outfile %li.fa -n_core %i -gapopen %i -profile FILE::prf.fa ", method, current->id,n_cores, gapopen);
				else
					sprintf(command, "t_coffee -output fasta_aln -method %s -quiet -outfile %s -n_core %i -gapopen %i   -profile FILE::prf.fa ", method, out_f, n_cores, gapopen);
				FILE *prf_F = my_fopen("prf.fa", "w");
				for(j=0; j<current->n_children;++j)
				{
					fprintf(prf_F, "%li.fa\n", current->children[j]->id);
				}
				fclose(prf_F);

				printf("%s\n", command);
				if (system(command))
				{

					printf("ERROR when running: %s\n",command);
					exit(1);
				}
				pop(to_do);
			}
//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:tcoffee,代码行数:101,代码来源:km_coffee.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ popEnabled函数代码示例发布时间:2022-05-31
下一篇:
C++ pool_unref函数代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap