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


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

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


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

示例1: CalcBothNotEmpty

bool SmallerBefore::CalcBothNotEmpty(const int value, std::stack<int>& stack1, std::stack<int>& stack2, std::vector<int>& S)
{
	if (value >= stack1.top() && value <= stack2.top())
	{
		stack1.push(value);
		S.push_back(stack1.size());
	}
	else if (value <= stack1.top())
	{
		while (! stack1.empty() && value < stack1.top())
		{
			stack2.push(stack1.top());
			stack1.pop();
		}
		stack1.push(value);
		S.push_back(stack1.size());
	}
	else if (value >= stack2.top())
	{
		while (! stack2.empty() && value >= stack2.top())
		{
			stack1.push(stack2.top());
			stack2.pop();
		}
		stack1.push(value);
		S.push_back(stack1.size());
	}

	return true;
}
开发者ID:elishemer,项目名称:SmallerBefore,代码行数:30,代码来源:SmallerBefore.cpp

示例2: freeObsDataSize

int freeObsDataSize()
{
  return 
    baseObsDataFreeStack.size() * sizeof(baseObsData) +
    fixedObsDataFreeStack.size() * sizeof(fixedObsData) +
    movingObsDataFreeStack.size() * sizeof(movingObsData);
}
开发者ID:jbuonagurio,项目名称:lrose-core,代码行数:7,代码来源:obsData.C

示例3: exec

void EvalStack::exec(char chr) {
  AttributeValue a, b, c;
  switch (chr) {
  case '+':
  case '-':
  case '*':
  case '/':
  case '>':
  case '<':
  case funcMin:
  case funcMax:
  case funcTable:
    if (vals.size() < 2) return;
    b = vals.top(); vals.pop();
    a = vals.top(); vals.pop();
    vals.push(binop(a, b, chr));
    break;
  case '~':
    if (vals.size() < 1) return;
    if (vals.top().text.empty()) {
      a = vals.top(); vals.pop();
      vals.emplace(-a.max, -a.min);
    }
    break;
  case ':':
    if (vals.size() < 3) return;
    c = vals.top(); vals.pop();
    b = vals.top(); vals.pop();
    a = vals.top(); vals.pop();
    vals.push(a.max ? b : c);
    break;
  }
}
开发者ID:prusswan,项目名称:SNOParser,代码行数:33,代码来源:description.cpp

示例4: renderRect

void Draw::renderRect()
{
std::stack <int> tempPoints;
std::stack <char *> tempColor;

tempPoints=pointlist;
tempColor=colorlist;

if (pointlist.size()/4!=(colorlist.size()))
std::cout<<"Error,mismatch between number of colors and points in the rectangle"<<std::endl;

    while(!tempPoints.empty())
{
int x = tempPoints.top();
tempPoints.pop();
int y = tempPoints.top();
tempPoints.pop();
int width = tempPoints.top();
tempPoints.pop();
int height = tempPoints.top();
tempPoints.pop();



drawRectangle(x,y,width,height,tempColor.top());

tempColor.pop();

}


}
开发者ID:gregf,项目名称:Maze-background,代码行数:32,代码来源:maze.cpp

示例5: perms

// I'm certain this function could be cleaned up, but it will require some
// serious brain storming, so it is a work in progress....
//
// The idea is I want to generate all possible permutations of RPN stacks given
// a set of 4 input integers.
void perms(std::set<int> possible, std::set<int>& all, std::stack<rpn_item> e, std::vector<rpn_item> const& ops) {
    // Once the stack is finished evaluate and add to the set
    if (e.size() == 7) {
        auto test = eval_rpn_stack(e);
        if (test > 0 && test != BAD_DIVIDE)
            all.insert(test);
        return;
    }

    // The very bottom of the stack MUST be an operator
    if (e.size() == 0) {
        for (auto i : ops) {
            auto tmp = e;
            tmp.push(i);
            perms(possible, all, tmp, ops);
        }
    }

    // the TOP 2 items in the stack MUST be integers
    if (e.size() >= 5) {
        for (auto i : possible) {
            auto tmp = possible;
            auto tmp_e = e;
            tmp.erase(i);
            tmp_e.push(i);
            perms(tmp, all, tmp_e, ops);
        }
    }

    // This is where things get messy...
    // I enumerate all possible stack configurations
    // There is no visible pattern that I can see and easily program so for now
    // this will remain a mess
    for (auto n1 = possible.begin(); n1 != possible.end(); ++n1) {
        for (auto n2 = std::next(n1); n2 != possible.end(); ++n2) {
            auto tmp_p = possible;
            tmp_p.erase(*n1); tmp_p.erase(*n2);
            for (auto op1 = ops.begin(); op1 != ops.end(); ++op1) {
                for (auto op2 = ops.begin(); op2 != ops.end(); ++op2) {
                    // op op n n
                    auto n = push_helper(e, {*op1, *op2, *n1, *n2});
                    perms(tmp_p, all, n, ops);
                    // op n op n
                    n = push_helper(e, {*op1, *n1, *op2, *n2});
                    perms(tmp_p, all, n, ops);
                    // n op n op
                    n = push_helper(e, {*n1, *op1, *n2, *op2});
                    perms(tmp_p, all, n, ops);
                    // op n n op
                    n = push_helper(e, {*op1, *n1, *n2, *op2});
                    perms(tmp_p, all, n, ops);
                    // n op op n
                    n = push_helper(e, {*n1, *op1, *op2, *n2});
                    perms(tmp_p, all, n, ops);
                }
            }
        }
    }
}
开发者ID:Quinny,项目名称:Online-Judge,代码行数:64,代码来源:093+Arithmetic+expressions.cpp

示例6: parameter

	bool parameter() {
		std::size_t old_stack_size = stack_.size();
		if (T::match(*this)) {
			reduce_stack(stack_.size() - old_stack_size);
			return true;
		} else
			return false;
	}
开发者ID:dondieselkopf,项目名称:tmp-parser,代码行数:8,代码来源:parser.hpp

示例7: pushVerbosity

void pushVerbosity(QudaVerbosity verbosity)
{
  vstack.push(getVerbosity());
  setVerbosity(verbosity);

  if (vstack.size() > 10) {
    warningQuda("Verbosity stack contains %u elements.  Is there a missing popVerbosity() somewhere?",
		static_cast<unsigned int>(vstack.size()));
  }
}
开发者ID:knippsch,项目名称:quda,代码行数:10,代码来源:util_quda.cpp

示例8: GetEndOfArrayOrObj

static size_t GetEndOfArrayOrObj(const std::string& str, std::stack<StackDepthType>& depth_stack)
{
	size_t i = 1;
	bool in_quote = false;
	size_t original_count = depth_stack.size();
	
	for (; i < str.length(); i++)
	{
		if (str[i] == '\"')
		{
			if (str[i - 1] != '\\')
				in_quote = !in_quote;
		}
		else if (!in_quote)
		{
			if (str[i] == '[')
				depth_stack.push(InArray);
			else if (str[i] == '{')
				depth_stack.push(InObject);
			else if (str[i] == ']')
			{
				StackDepthType t = depth_stack.top();
				if (t != InArray)
				{
					// expected to be closing an array but instead we're inside an object block.
					// Example problem: {]}
					return std::string::npos;
				}
				
				size_t count = depth_stack.size();
				depth_stack.pop();
				if (count == original_count)
					break;
			}
			else if (str[i] == '}')
			{
				StackDepthType t = depth_stack.top();
				if (t != InObject)
				{
					// expected to be closing an object but instead we're inside an array.
					// Example problem: [}]
					return std::string::npos;
				}
					
				size_t count = depth_stack.size();
				depth_stack.pop();
				if (count == original_count)
					break;
			}
		}
	}
	
	return i;
}
开发者ID:gitter-badger,项目名称:robotmoose,代码行数:54,代码来源:json.cpp

示例9: pe

bool pe(std::stack<char> &a, std::stack<char> &b) {
  if(a.size() != b.size())
    return false;
  while(!a.empty()) {
    if(a.top() != b.top())
      return false;
    a.pop();
    b.pop();
  }
  return true;
}
开发者ID:LasseD,项目名称:uva,代码行数:11,代码来源:P10188.cpp

示例10: printStack

//*******************************************************
// Parser::printStack
//*******************************************************
void Parser::printStack(std::ostream &theOS,
                        std::stack<std::shared_ptr<Symbol>> theStack)
{
  while (theStack.size() > 0)
  {
    theOS << *(theStack.top());
    theStack.pop();
    if (theStack.size() > 0)
    {
      theOS << " ";
    }
  }
}
开发者ID:michaeljohnalbers,项目名称:UniversalCompiler,代码行数:16,代码来源:Parser.cpp

示例11: back

void back(void)
{
    if (menu_pages.size() > 1)
    {
        menu_pages.pop();
    }
}
开发者ID:mastergreg,项目名称:pewpew,代码行数:7,代码来源:pewpew.cpp

示例12: processUnaryOp

void PostfixExprEvaluator::processUnaryOp(const Token &token,
	                                      std::stack<Token> &operands)
{
	assert(token.type == TokenType::TOK_UNARYOP);

	// ensure stack contains one operand
	if (operands.size() < 1)
	{
		throw StackUnderflowException();
	}

	// fetch operand off the stack
	auto operand = operands.top(); operands.pop();

	if (operand.type == TokenType::TOK_INT)
	{
		operand = castIntToFloat(operand);
	}

	Token opResult;
	
	opResult.type = TokenType::TOK_FLOAT,
	opResult.value.valueFloat = evalUnaryOp<float>(
		operand.value.valueFloat,
		static_cast<OpUnary>(token.value.valueInt));

	operands.push(opResult);
}
开发者ID:osmehlik,项目名称:arithmetic-expression-parser,代码行数:28,代码来源:PostfixExprEvaluator.cpp

示例13: start_elem

    int start_elem(const std::string &elem){
        // new tag, clean content;
        current.clear();

        // check XML nested level, security protection
        if(stack_status.size() < 200){
            stack_status.push(elem);
        }else{
            throw DavixException(davix_scope_xml_parser(), StatusCode::ParsingError, "Impossible to parse S3 content, corrupted XML");
        }

        // check element, if it is "deleted" this recource has beed deleted successfully
        // or the resource did not exist in the first place, either way, log it 
        if( StrUtil::compare_ncase(delete_prop, elem) ==0){
            DAVIX_SLOG(DAVIX_LOG_TRACE, DAVIX_LOG_XML, "deleted entry found", elem.c_str());
            status.clear();
            entry_count = 0;
        }

        // check element, if "Error" there has been problem with deleting this resource
        // the code returned will have to be mapped to http code
        if( StrUtil::compare_ncase(error_prop, elem) ==0){
            DAVIX_SLOG(DAVIX_LOG_TRACE, DAVIX_LOG_XML, "error entry found", elem.c_str());
            status.clear();
            status.error = true;
            entry_count = 0;
        }


        return 1;
    }
开发者ID:ayllon,项目名称:davix,代码行数:31,代码来源:s3deleteparser.cpp

示例14: defaultAfter

   indri::lang::Node* defaultAfter( indri::lang::Node* oldNode, indri::lang::Node* newNode ) {
     if( _disqualifiers.size() && oldNode == _disqualifiers.top() )
       _disqualifiers.pop();
 
     _nodes.push_back( newNode );
     return newNode;
   }
开发者ID:danrugeles,项目名称:retrieval-algorithms,代码行数:7,代码来源:FrequencyListCopier.hpp

示例15: get_check_point

 check_point get_check_point()const
 {
    if ( check_points.size()){
    return check_points.top();
    }
    return check_point("throw point" ,this->get_source_pos(),this->get_stream_id());
 }
开发者ID:duststorm,项目名称:quan-trunk,代码行数:7,代码来源:istream.hpp


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