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


C++ stack::pop方法代码示例

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


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

示例1: pop

 // Removes the element from in front of queue.
 void pop(void) {
     pushIntoQueue();
     if (!queue.empty())
         queue.pop();
 }
开发者ID:forehalo,项目名称:leetcode,代码行数:6,代码来源:Implement_Queue_using_Stacks.cpp

示例2: string


//.........这里部分代码省略.........
			temp_relations.push_back(temp_table_name  ) ;
			for(vector<Tuple>::iterator tit = temp.begin(); tit != temp.end(); tit++){
				Tuple t = rlt->createTuple() ;
	
				for(vector<string>::iterator it = field_names.begin(); it != field_names.end() ; it++){
					union Field f= tit->getField(*it) ;
					if( s.getFieldType(*it) == INT ){
						t.setField(  *it,  f.integer ) ;
					}else{
						t.setField( *it, *(f.str)) ;
					}
				}
				ret.push_back( t ) ;
			}
		}else{
			return ret;
		}
	}else if(this->type == PRODUCT){
		vector<string> ptables;
		vector<Relation *> relations ;
		map<string, Qexpression *> sigma_operation ;
		vector<string> commons ;
		map<string, bool> joined_keys;

		vector<string>::iterator it = ptables.begin();

		ptables.insert(ptables.end(), this->info.begin(), this->info.end() );
		
		if(output_s.empty() ){
		}else if(output_s.top()->type == INTEGER || output_s.top()->type == LITERAL ){
			Tuple *t = NULL;
			if(output_s.top()->judge(*t) ){
				/* WHERE clasuse always true */
		 		 while(! output_s.empty() ){ output_s.top()->free() ;output_s.pop();}
			}else{
				/* empty results */
				return ret; 
			}
		}else{
			Qexpression *optimized = output_s.top()->optimize_sigma(&sigma_operation) ;
			output_s.pop(); if(optimized != NULL){ output_s.push(optimized) ;}
			
			#ifdef DEBUG
			for(map<string, Qexpression *>::iterator it = sigma_operation.begin(); it != sigma_operation.end(); it ++){
				cout << it->first << "->" << endl;
				it->second->print(0);
			}
			#endif

			if( ! output_s.empty() ){
				optimized = output_s.top()->optimize_join(commons, joined_keys) ;
				output_s.pop(); 
				if(optimized != NULL){ 
					output_s.push(optimized) ;
				}else{
					while(! output_s.empty() ){output_s.top()->free() ; output_s.pop();}
				}

				if(! output_s.empty()){
					#ifdef DEBUG
					output_s.top()->print(0); 
					#endif
				}
			}
			#ifdef DEBUG
			cerr << "commons: ";
开发者ID:xvxiaopei,项目名称:Database,代码行数:67,代码来源:main.cpp

示例3: main

int main()
{

freopen("input.txt","r",stdin);

	int N, M;
	string tmpStatus;
	while ( cin >> N >> M, N!=0 && M!=0 )
	{
		// 初始化
		while ( !oldStates.empty() )
			oldStates.pop();
		for ( int i = 0; i < 50; i++ )
		{
			target[i] = false;
			for ( int j = 0; j < 27; j++ )
				states[i][j].clear();
		}
		
		// 读取转化表
		for ( int i = 0; i < N; i++ )
		{	
			for ( int j = 0; j < M; j++ )
			{
				cin >> tmpStatus;
				stringToVector( tmpStatus, states[i][j] );
			}
		}
		
		STATUS tmp;
		while ( cin >> tmp, tmp != -1 )
		{
			target[tmp] = true;
		}

		while ( cin >> str, str != "#" )
		{
			idx = 0;

			// 把开始状态压进oldStates中,开始搜索
			oldStates.push( 0 );
			moveOneStepAndClosure( 'E' );

			char c = nextChar();
			while( idx != str.length()+1 )
			{
				// 实现:S = e_closure( move( S, c ) );
				moveOneStepAndClosure( c );
				
				c = nextChar();
			}

			if ( isInTarget( oldStates ) )
				cout << "YES" << endl;
			else
				cout << "NO" << endl;

		}
	}

	return 0;
}
开发者ID:JacobPan3g,项目名称:C,代码行数:62,代码来源:NFA.cpp

示例4: main

int main(int argc, char** argv)
{
	// Shutdown automatically.
	atexit(Shutdown);

	// Enable debugging output.
	PosixSerial::debugging(false);
	Surveyor::debugging(false);

	// To which Surveyor are we connecting?
	string devName = "/dev/ttyUSB0";
	if (argc > 1) {
		devName = argv[1];
	}

	// Connect to the Surveyor.
	// WARNING: Camera resolution MUST be 160x128 for blob finding to work.
	// I was puzzled for hours until I figured this out.
	if ((srv = CreateSurveyor(devName, Surveyor::CAMSIZE_160x128, 5)) == 0) {
		cerr << "Failed to connect to the Surveyor." << endl;
		exit(-1);
	}

	// Initialize SDL.
	if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
		cerr << "Failed to initialize SDL: " << SDL_GetError();
		exit(-1);
	}
	screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_DOUBLEBUF);
	if (screen == 0) {
		cerr << "Failed to set video mode: " << SDL_GetError();
		exit(-1);
	}
	SDL_WM_SetCaption(APP_TITLE, 0);

	// Create our mutexes.
	if ((srvMutex = SDL_CreateMutex()) == 0 ||
		(jpegImageMutex = SDL_CreateMutex()) == 0 ||
	    (blobImageMutex = SDL_CreateMutex()) == 0) {
		cerr << "Failed to create mutex: " << SDL_GetError();
		exit(-1);
	}

	if ((blobThread = SDL_CreateThread(BlobFinder, 0)) == 0) {
		cerr << "Failed to start blob finder: " << SDL_GetError() << endl;
		exit(-1);
	}

	// Enter main loop.
	bool fQuitApplication = false;
	while (!fQuitApplication) {
		// Handle all events.
		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			switch (event.type) {
				case SDL_QUIT: {
					fQuitApplication = true;
				} break;
				case SDL_KEYDOWN: {
					switch (event.key.keysym.sym) {
						case SDLK_ESCAPE: {
							fQuitApplication = true;
						} break;
						case SDLK_i: { // Image
							if (!fUpdatingImage) {
								if ((imageThread = SDL_CreateThread(UpdateImage, 0)) == 0) {
									cerr << "Failed to get image: " << SDL_GetError() << endl;
								} else {
									fUpdatingImage = true;
								}
							}
						} break;
						case SDLK_u: { // Undo
							if (!undoList.empty()) {
								currentRange =  newRange = undoList.top();
								undoList.pop();
								fYUVRangeChange = true;
							}
						} break;
						case SDLK_r: { // Reset
							currentRange = newRange = YUVRange("FF00FF00FF00");
							fYUVRangeChange = true;
						} break;
						case SDLK_p: { // Print
							cout << endl;
							cout << "Hex: " << currentRange.toHexString() << '\n'
							     << "Y-range: " << setw(5) << currentRange.getYMin() << " - " << setw(3) << currentRange.getYMax() << '\n'
							     << "U-range: " << setw(5) << currentRange.getUMin() << " - " << setw(3) << currentRange.getUMax() << '\n'
							     << "V-range: " << setw(5) << currentRange.getVMin() << " - " << setw(3) << currentRange.getVMax() << '\n';
							cout << endl;
						} break;
						default: {
						} break;
					}
				} break;
				case SDL_MOUSEBUTTONDOWN: {
					if (event.button.button == SDL_BUTTON_LEFT) {
						mouseX1 = mouseX2 = event.button.x;
						mouseY1 = mouseY2 = event.button.y;
						if (mouseX1 >= 0 && mouseX1 < IMAGE_WIDTH &&
//.........这里部分代码省略.........
开发者ID:Arkainium,项目名称:PlayerSRV,代码行数:101,代码来源:main.cpp

示例5: intersect


//.........这里部分代码省略.........

        t1 = (-b+sqrt(disc))/(2*a);
        t2 = (-b-sqrt(disc))/(2*a);

        if (t1>t2)
        {
            float temp = t1;
            t1 = t2;
            t2 = temp;
        }

        //now always t1<t2

        if (t2<0) //both of them are negative
        {
            result = false;
        }
        else
        {
            result = true;
            if (t1<0)
            {
                t = t2;
            }
            else
            {
                t = t1;
            }

            if ((h.time<0) || (h.time>t))
            {
                glm::vec4 ptIntersect;

                ptIntersect = objectRay.start + objectRay.dir*t;

                h.time = t;
                h.point = objToView * ptIntersect;
                h.normal = glm::transpose(viewToObj) * glm::vec4(ptIntersect.x,ptIntersect.y,ptIntersect.z,0);
                h.normal = glm::normalize(h.normal);
                h.mat = material;

                h.tex = this->getTexture();

                //bound x and y to be bewtween 1 and -1
                if(ptIntersect.x > 1)
                {
                    ptIntersect.x = 1;
                }
                else if(ptIntersect.x < -1)
                {
                    ptIntersect.x = -1;
                }

                if(ptIntersect.y > 1)
                {
                    ptIntersect.y = 1;
                }
                else if(ptIntersect.y < -1)
                {
                    ptIntersect.y = -1;
                }

                //y = sin(theta), use to find theta
                theta = asin(fabs(ptIntersect.y));

                //other side of sphere

                if(ptIntersect.y < 0 )
                {
                    theta = -theta;
                }


                phi = acos(fabs(ptIntersect.x) / cos(theta));

                if(ptIntersect.z < 0)
                {
                    if(ptIntersect.x < 0)
                    {
                        phi = pi - phi;
                    }
                }
                else if(ptIntersect.x < 0)
                {
                    phi = pi + phi;
                }
                else
                    phi = 2*pi - phi;

                texS = phi / (2*pi);
                texT = 1-((theta + (pi/2)) / pi);

                h.textCoords = glm::vec4(texS,texT,0,1);
            }
        }
    }

    modelview.pop();
    return result;
}
开发者ID:Software-Steve,项目名称:RayTracer,代码行数:101,代码来源:Sphere.cpp

示例6: hierarchy_exit

void chdl::hierarchy_exit() {
  hstack.pop();
}
开发者ID:nickchenyj,项目名称:chdl,代码行数:3,代码来源:hierarchy.cpp

示例7: strcat

//中缀转前缀 
char *qianzhui(char *ss,int n)
{
    int i,j,m=0;
    char swap;
    char t;
    
    
	n++;
    char *temp=new char[n];
    char *a=new char[n];
    a[0]='#';
    a[1]='\0';
    strcat(a,ss);


    for (i=n-1;i>=0;i--)
    {
        if (isdigit(a[i]))
        {
            temp[m]=a[i];
            m++; 
        }
        else
        {

            if (a[i]==')')
                expe.push(')');
            else
                if (a[i]=='(')
                {
                    while (expe.top()!=')')
                    {
                        temp[m]=expe.top();
                        m++;
                        expe.pop();
                    }
                    expe.pop();
                }
                else
                {
                    while ((!expe.empty())&&(pri[expe.top()]>pri[a[i]]))
                    {
                        temp[m]=expe.top();
                        m++;
                        expe.pop();
                    }
                    expe.push(a[i]);
                }
        }
    }
    
    temp[m]='\0';
    m++;
    
    for (i=0;i<m/2;i++)
    {
    	swap=temp[i];
    	temp[i]=temp[m-i-2];
    	temp[m-i-2]=swap;
    }

    return temp;

}
开发者ID:blackbbc,项目名称:Data-Structure-Projects,代码行数:65,代码来源:main.cpp

示例8: pop

 void pop() {
   if (s.top() == min.top()) {
     min.pop();
   }
   s.pop();
 }
开发者ID:erichuang1994,项目名称:leetcode-solution,代码行数:6,代码来源:155.+Min+Stack.cpp

示例9: dfs


//.........这里部分代码省略.........
    if(state->board == goal->board) {
        // 検索結果を出力
        output(result, state, board_width, board_height);

        return true;
    }
    else {
        // 次の手で移動可能な全ての局面に対して
        for(int i = 0; (n = adjacent[state->space][i]) != -1; i++) {
            b = state->board;
            panel = b[n];

            // スワップの対象が壁でない場合
            if(state->block[n] != '=') {
                // スワップ
                b[state->space] = b[n];
                b[n] = '0';

                // 既に登録された局面の場合
                if(hs.find(b) != NULL) {
                    continue;
                }
                // 登録されていない新しい局面の場合
                else {
                    // 動かしたパネルの差分だけ計算
                    diff_ID = invert_distance(state->board) - invert_distance(b);
                    diff_MD = manhattan_distance(panel, state->space+1) - manhattan_distance(panel, n+1);

                    // より大きい(厳しい)値を採用する
                    //if(diff_MD > diff_ID)
                        cost = state->cost + diff_MD; // コストの更新
                        //else
                        //cost = state->cost + diff_ID; // コストの更新

                    // 移動可能な局面状態をリストに追加
                    buff.push_front(Cost_Attribute(cost, Options(b, state)));
                }
            }
        }

        // もしリストに追加されていた場合
        if(buff.size() > 0) {
            // コストの最も小さい局面から選択されるように並び替え
            buff.sort();

            for(it = buff.begin(); it != buff.end(); it++) {
                /*
                // クラスメンバへのポインタの定義
                int Cost_Attribute::*  mp_cost;
                Options Cost_Attribute::* mp_attribute;
                string Options::* mp_board;
                STATE Options::* mp_state;

                int candidate_cost = (*it).*mp_cost;
                string candidate_board = (*it).*mp_attribute.*mp_board;
                STATE candidate_state = (*it).*mp_attribute.*mp_state;
                string candidate_block = ((*it).*mp_attribute.*mp_state)->block;
                int candidate_space;
                */

                int candidate_cost = (*it).first;
                string candidate_board = (*it).second.first;
                STATE candidate_state = (*it).second.second;
                string candidate_block = (*candidate_state).block;
                int candidate_space;

                // 空白の位置
                for(int i = 0; i < candidate_board.size(); i++) {
                    if(candidate_board[i] == '0')
                        candidate_space = i;
                }

                STATE c = new struct State;

                c->board = candidate_board;
                c->space = candidate_space;
                c->block = candidate_block;
                c->prev_state = candidate_state;
                c->cost = candidate_cost;

                // 局面状態の先頭への追加
                dfs_stack.push(c);
                hs.addPair(c->board);

                // 再帰
                if(dfs(result, c, goal, dfs_stack, hs, adjacent)) {
                    delete c;

                    return true;
                }
                else
                    // 先頭からの局面状態の取り出し
                    dfs_stack.pop();

            }// for
        }// if
    }

    return false;
}
开发者ID:Goto-youthK,项目名称:search_algorithm,代码行数:101,代码来源:df_search.cpp

示例10: pop

 void pop(void) {
     peek();
     output.pop();
 }
开发者ID:yqtaowhu,项目名称:LeetCode-Solutions,代码行数:4,代码来源:ImplementQueueUsingStacks.cpp

示例11: pop

 void pop() {
     stk.pop();
     minEle.pop();
 }
开发者ID:Lingfei-Li,项目名称:leetcode,代码行数:4,代码来源:155.MinStack.cpp

示例12: showstack

void showstack(stack s)
{
  cout << "show stack:\n";
  int i;
  for(i=0; i<SIZE; i++) cout << s.pop() << "\n";
}
开发者ID:shun-tak,项目名称:teach_yourself_cpp,代码行数:6,代码来源:ex3.2.1.cpp

示例13: pop

 void pop() {
     move();
     s2.pop();
 }
开发者ID:foxboy26,项目名称:practice,代码行数:4,代码来源:queueByTwoStack.cpp

示例14: main

int main()
{
	#ifdef fn
		freopen(fn ".in", "r", stdin);
		freopen(fn ".out", "w", stdout);
	#endif
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
	{
		if (s[i] == '(' || s[i] == '[')
			st.push(i);
		if (s[i] == ')')
		{
			if (!st.empty() && s[st.top()] == '(')
			{
				pr[i] = st.top(), st.pop();
				pr[pr[i]] = i;
			}
			else
			{
				while (!st.empty())
					pr[st.top()] = -1, st.pop();
				pr[i] = -1;
			}
		}
		if (s[i] == ']')
		{
			if (!st.empty() && s[st.top()] == '[')
			{
				pr[i] = st.top(), st.pop();
				pr[pr[i]] = i;
			}
			else
			{
				while (!st.empty())
					pr[st.top()] = -1, st.pop();
				pr[i] = -1;
			}
		}
	}
	while (!st.empty())
		pr[st.top()] = -1, st.pop();
//	for (int i = 1; i <= n; i++)
//		printf("%d ", pr[i]);
//	puts("");
	for (int i = 1; i <= n; i++)
		a[i] = a[i - 1] + (s[i] == '[');
	int L = 0, R = -1, l = -1, r = -1, ans = 0;
	for (int i = 1; i <= n;)
	{
		if (pr[i] == -1)
		{
			if (l != -1 && umax(ans, a[r] - a[l - 1]))
				L = l, R = r;
			l = -1, r = -1;
			i++;
		}
		else
		{
			if (l == -1)
				l = i;
			r = pr[i];
			i = pr[i] + 1;
		}
	}
	if (l != -1 && umax(ans, a[r] - a[l - 1]))
		L = l, R = r;
	printf("%d\n", ans);
	for (int i = L; i <= R; i++)
		putchar(s[i]);
}
开发者ID:MannyFM,项目名称:Codeforces,代码行数:72,代码来源:a.cpp

示例15: print

void print(stack<int> my_tour) {
    while (!my_tour.empty()) {
        int top = my_tour.top(); cout << top << ' ';
        my_tour.pop();
    }
}
开发者ID:lantimilan,项目名称:topcoder,代码行数:6,代码来源:EulerTour.cpp


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