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


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

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


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

示例1: MenuException

 virtual shared_ptr<MenuComponent> move(MenuLeaf& m, KeyButton& k) {
   switch (k.get_key()) {
     case BUTTON_UP:
       return (history.top().get().get_previous_element());
     case BUTTON_DOWN:
       return (history.top().get().get_next_element());
     case BUTTON_LEFT:
       if (history.size() > 1) {
         history.top().get().home();
         history.pop();
       }
       return (history.top().get().get_active_element());
     case BUTTON_RIGHT:
       return (history.top().get().get_active_element());
     default:
       throw MenuException((string("Unexpected key ") + string(k)).c_str());
       break;
   }
 }
开发者ID:danieleatgithub,项目名称:Homer,代码行数:19,代码来源:MoveVisitor.hpp

示例2: shift_reduce

            bool shift_reduce( const T& c ) {
                while ( stack_.top().distance() < width_ ) {
                    // && stack_.top().type() == peakfind::Down ) { // discard narrow 'down' state
                    stack_.pop();
                    if ( stack_.empty() ) {
                        stack_.push( c );
                        return false;
                    }
                }

                if ( stack_.top().type() == c.type() )  // marge
                    stack_.top() += c;  // marge

                // if (Up - Down)|(Down - Up), should push counter and wait for next state
                if ( stack_.top().type() != c.type() )
                    stack_.push( c );

                return stack_.size() >= 3;
            };
开发者ID:hermixy,项目名称:qtplatz,代码行数:19,代码来源:spectrum_processor.cpp

示例3: main

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d %d", lf+i, rg+i);
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (lf[i] > lf[j] && rg[i] < rg[j])
                adj[j].push_back(i);
        }
    }

    int maxi = 0;
    for (int i = 0; i < n; i++)
        hei[i] = -1;

    for (int i = 0; i < n; i++) {
        dfs(i);
        if (hei[maxi] < hei[i])
            maxi = i;
    }
    
    printf("%d\n", hei[maxi]);

    while (hei[maxi] != 1) {
        st.push(maxi+1);
        for (int i = 0; i < adj[maxi].size(); i++) {
            if (hei[adj[maxi][i]] == hei[maxi] - 1) {
                maxi = adj[maxi][i];
                break;
            }
        }
    }
    st.push(maxi+1);

    while (st.size() > 1) {
        printf("%d ", st.top());
        st.pop();
    }

    printf("%d\n", st.top());
}
开发者ID:victorsenam,项目名称:treinos,代码行数:43,代码来源:1078.cpp

示例4: GFXPopGlobalEffects

GFXBOOL /*GFXDRVAPI*/ GFXPopGlobalEffects()
{
    if ( GlobalEffects.empty() )
        return false;
    //VSFileSystem::Fprintf (stderr,"GES %d",GlobalEffects.size());
    for (int i = 0; i < GFX_MAX_LIGHTS; i++)
        if (GlobalEffects.top()[i])
            glEnable( GL_LIGHT0+i );
    
    if (GlobalEffectsFreelist.size() >= 10)
        delete[] GlobalEffects.top();
    else
        GlobalEffectsFreelist.push(GlobalEffects.top());
    GlobalEffects.pop();
    
    GFXLightContextAmbient( GlobalEffectsAmbient.top() );
    GlobalEffectsAmbient.pop();
    return true;
}
开发者ID:vegastrike,项目名称:Vega-Strike-Engine-Source,代码行数:19,代码来源:gl_light.cpp

示例5: main

int main()
{
    int i,n;
    char s;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>s;
        if(st.empty()){
            st.push(s);
            continue;
        }
        char r=st.top();
        if(r!=s){
            st.pop();
        }else{
            st.push(s);
        }
    }
    cout<<st.size();
}
开发者ID:caoyi0905,项目名称:codeforces-solutions,代码行数:20,代码来源:556A.cpp

示例6: op

 void op(string& opCode)
 {
   if(s.size() >= 2) {
     double a = s.top(); s.pop();
     double b = s.top(); s.pop();
     double result;
          if(opCode == "+") result = b + a;
     else if(opCode == "-") result = b - a;
     else if(opCode == "*") result = b * a;
     else if(opCode == "/") result = b / a;
     else if(opCode == "%") result = fmod(b, a);
     else {
       cout << "unknown operator " << opCode << "\n";
       return;
     }
     cout << result << "\n";
     s.push(result);
   } else
     cout << "need two numbers\n";
 }
开发者ID:OpsRaven,项目名称:SenecaOOP345-attic,代码行数:20,代码来源:stl-calc-stack.cpp

示例7: handleSelfCloseTags

/* ------------------------------- To handle self closing tags on stack ----------------------------------*/
void XMLParser::handleSelfCloseTags(XmlReader newxrdPtr, stack<shared_ptr <AbstractXmlElement>> &impStack, string element, string temp, size_t s)
{
	using sPtr = shared_ptr < AbstractXmlElement >;
	if (impStack.size() != 0){
		sPtr pop0 = impStack.top();
		impStack.pop();
		newxrdPtr.position(s + 1);

		sPtr child = makeTaggedElement(newxrdPtr.tag());
		if (containsTagsText(newxrdPtr, child)){}
		containsAttribute(newxrdPtr, child);
		child->selfCloseTag(1);

		if (pop0->numofChild() > 0)	{
			pop0->addChild(child);
			pop0->getNumofChilds(pop0->numofChild() - 1);
			impStack.push(pop0);
		}
	}
}
开发者ID:arunbalaji91,项目名称:XML-Document-Model,代码行数:21,代码来源:XMLParser.cpp

示例8: item

// Display the stack in "pop" order
template<> void debug::dump<stack<int>>(const string& msg,  const stack<int>& indecies)  noexcept
{
    cout << msg;
    
    struct Hack : public stack<int> {

        static int item(int i, const stack<int>& stack_ref)
        {
            return (stack_ref.*&Hack::c)[i];
        }
    };
    
    for(int i = indecies.size() - 1; i >= 0;  --i) {
      //    for(int i = 0;  i < indecies.size();  ++i) {

        cout << Hack::item(i, indecies) << ", ";
    }

    cout << endl;
}
开发者ID:kkruecke,项目名称:23tree-in-cpp,代码行数:21,代码来源:debug.cpp

示例9: infixToPostfix

char* infixToPostfix(char *s){
	int i=0;	//loop variable
	int prior,n;
	char *postfix;
	while(s[i]!='\0'){
		prior=priority(s[i]);
		if(prior<0)
			expres.push(s[i]);
		else insert(s[i],prior);
		i++;
	}
	while(!aux.empty()){
		expres.push(aux.top());
		aux.pop();
	}
	n=expres.size();
	postfix=new char[n+1];
	FOR(i,n){
		postfix[n-i-1]=expres.top();
		expres.pop();
	}
开发者ID:Vijeta141,项目名称:SportProgramming,代码行数:21,代码来源:infixToPostfix.cpp

示例10: undo

//This is also a helper function for UNDO command, return the previous turn result
void Board::undo() {
	if (undo_counter < 10) {
		if (undo_list.size() != 0) {      //undo_list contains some previous turns
			gameboard = undo_list.top();
			undo_list.pop();
			if (previous_turn() == 1) {
				undo();
			}
			else {              //undo_list is empty
				turn = -1;
				undo_counter++;
				show();
				cout << 10 - undo_counter << " UNDO remain\n";
			}
		}
		else
			cout << "no more undo steps" << endl;
	}
	else
		cout << "at most undo 10 times\n";
}
开发者ID:14nguyenh,项目名称:Reversi,代码行数:22,代码来源:newserver.cpp

示例11: push

void specialStack::push(int data){
	s.push(data);
	if(sm.empty()){
		Min *tmp = new Min;
		tmp->data = data;
		tmp->ind = 0;
		sm.push(tmp);
	}
	else {
		Min *t = sm.top();
		if(t->data < data){
			sm.top()->ind++;
		}
		else {
			Min *tmp = new Min;
			tmp->data = data;
			tmp->ind = s.size()-1;
			sm.push(tmp);
		}
	}
}
开发者ID:linearregression,项目名称:geeksforgeeks,代码行数:21,代码来源:8.design-and-implement-special-stack-data-structure.cpp

示例12: fact

inline llint fact( llint n ) {
    llint ret = 1;
    int l1,l2;
    l1 = prost.size();
    for( int x = 0; x < l1 && n != 1; x++ ) {
        uzet.push( x );
        while( n % prost[x] == 0 )
            n /= prost[x], niz[x] *= prost[ x ];
        if( niz[ x ] == 1 )
            uzet.pop();
    }
    if( n != 1 ) {
        ret *= calc( n, n );
    }
    while( uzet.size() ) {
        ret *= calc( niz[ uzet.top() ], prost[ uzet.top() ] );
        niz[ uzet.top() ] = 1;
        uzet.pop();
    }
    return ret;
}
开发者ID:marko1597,项目名称:Programming-competitions,代码行数:21,代码来源:DIVSUM.cpp

示例13: handleProcInstr

/* ------------------------------- To handle Process Instructions ----------------------------------*/
void XMLParser::handleProcInstr(XmlReader newxrdPtr, stack<shared_ptr <AbstractXmlElement>> &impStack, string element, string temp, size_t s)
{
	using sPtr = shared_ptr < AbstractXmlElement >;
	if (impStack.size() != 0)	{
		sPtr pop0 = impStack.top();
		impStack.pop();

		newxrdPtr.position(s + 1);
		sPtr child = makeProcInstrElement(newxrdPtr.tag());
		s = newxrdPtr.tag().size() + 1;
		vector<string> attrvalue = getManualAttre(getString(s, temp.size() -1 , temp));
		for (size_t i = 0; i < attrvalue.size(); i += 2)
		{	child->addAttrib(attrvalue[i], attrvalue[i + 1]);	}
		child->selfCloseTag(1);
		if (pop0->numofChild() > 0){
			pop0->addChild(child);
			pop0->getNumofChilds(pop0->numofChild() - 1);
			impStack.push(pop0);
		}
	}
}
开发者ID:arunbalaji91,项目名称:XML-Document-Model,代码行数:22,代码来源:XMLParser.cpp

示例14: sort_root

void sort_root(vector<int> &v)
{
	vector<vstore> values, temp;
	vector<vstore>::iterator it;
	vstore pop;
	while (sstore.size() != 0)
	{
		pop = sstore.top();
		temp.push_back(pop);
		sstore.pop();
	}
	while (temp.size() != 0)
	{
		values.push_back(temp[temp.size() - 1]);
		temp.pop_back();
	}
	size_t least = 0;
	for (int i = 0; i < values.size() - 1; i++)
	{
		least = i;
		for (int j = i + 1; j < values.size(); ++j)
		{
			if (v[values[j].second] < v[values[least].second])
			{
				cond_check = 1;
				least = j;
			}
		}
		int idx = values[least].second; 
		int temp = v[idx];
		int idx1 = values[i].second;
		int temp1 = v[idx1];
		v[values[i].second] = temp;
		v[values[least].second] = temp1;
	}
	for (int i = 0; i < values.size(); i++)
	{
		sstore.push(values[i]);
	}
}
开发者ID:arunbalaji91,项目名称:smooth-sort,代码行数:40,代码来源:smooth_sort.cpp

示例15: ptdDoPaintSingleDot

//////////////////////////////////////////////////////////////////////////
// 在dc上绘制单个点像素
void ptdDoPaintSingleDot(HDC hdc)
{
	if (flag == 0)
	{

		num = rand() % max_num;
		COLORREF color;
		pair<int, int> temp_pots;
		temp_pots.first = gaussrand(arr[num][0] * 13, 5);
		temp_pots.second = gaussrand(arr[num][1] * 13, 5);
		pots_stack.push(temp_pots);
		if (pots_stack.size() > 18000)
		{
			flag = 1;
		}
		if (arr[num][5] == 1)
		{
			color = RGB(255, gaussrand(arr[num][3] * 0.5, 60), gaussrand(arr[num][4] * 0.5, 60));
		}
		else
		{
			color = RGB(arr[num][2] * 1.2, 255, arr[num][4] * 1.2);
		}

		SetPixel(hdc, temp_pots.first, temp_pots.second, color);
	}
	else
	{
		SetPixel(
			hdc,
			pots_stack.top().first,
			pots_stack.top().second,
			RGB(0, 0, 0));
		pots_stack.pop();
		if (pots_stack.empty())
		{
			flag = 0;
		}
	}
}
开发者ID:DengZuoheng,项目名称:eveApple,代码行数:42,代码来源:源.cpp


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