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


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

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


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

示例1: pPopMatrix

//Pop
void pPopMatrix(){
    projection.pop();
}
开发者ID:ndahlquist,项目名称:nautilus,代码行数:4,代码来源:transform.cpp

示例2: next

	void next()
	{
		assert(_stack.size());
		node *p = _stack.top();
		_stack.pop();

		auto &gl = p->group_list;

		// acceptable state
		if (gl.empty()) {
			p->print();
			delete p;
			return;
		}

		// branch the first group
		const int start0 = gl[0].first;
		const int end0 = gl[0].second;
		for (int i = start0 + 2; i < end0; i++) {
			auto *tmp = new node;
			tmp->edge_list = p->edge_list;
			tmp->edge_list.push_back(make_pair(start0, i));
			tmp->group_list.reserve(gl.size() + 1);
			tmp->group_list.push_back(make_pair(start0+1, i-1));
			tmp->group_list.push_back(make_pair(i+1, end0));
			for (int j = 1; j < gl.size(); j++)
				tmp->group_list.push_back(gl[j]);
			_stack.push(tmp);
		}
		// edge case of the first group
		if (end0 - start0 > 1) {
			auto *tmp = new node;
			tmp->edge_list  = p->edge_list;
			tmp->edge_list.push_back(make_pair(start0, end0));
			tmp->group_list = p->group_list;
			tmp->group_list[0] = make_pair(start0+1, end0-1);
			_stack.push(tmp);
		}

		// branch the remaining groups, if any
		if (gl.size() == 1) {
			delete p;
			return;
		}
		for (int i = 1; i < gl.size(); i++) {
			const int start = gl[i].first;
			const int end = gl[i].second;
			if (end - start == 0) {
				auto *tmp = new node;
				tmp->edge_list = p->edge_list;
				tmp->edge_list.push_back(make_pair(start0, start));
				tmp->group_list.reserve(gl.size() + 1);
				if (end0 - start0)
					tmp->group_list.push_back(make_pair(start0+1, end0));
				for (int k = 1; k < i; k++)
					tmp->group_list.push_back(gl[k]);
				for (int k = i+1; k < gl.size(); k++)
					tmp->group_list.push_back(gl[k]);
				_stack.push(tmp);
				continue;
			}
			// end > start
			for (int j = start; j <= end; j++) {
				auto *tmp = new node;
				tmp->edge_list = p->edge_list;
				tmp->edge_list.push_back(make_pair(start0, j));
				tmp->group_list.reserve(gl.size() + 1);
				if (end0 - start0)
					tmp->group_list.push_back(make_pair(start0+1, end0));
				for (int k = 1; k < i; k++)
					tmp->group_list.push_back(gl[k]);

				if (j == start) {
					tmp->group_list.push_back(make_pair(start+1, end));
				} else if (j == end) {
					tmp->group_list.push_back(make_pair(start, end-1));
				} else {
					tmp->group_list.push_back(make_pair(start, j-1));
					tmp->group_list.push_back(make_pair(j+1, end));
				}

				for (int k = i+1; k < gl.size(); k++)
					tmp->group_list.push_back(gl[k]);
				_stack.push(tmp);
			}
		}
		delete p;
	}
开发者ID:qzmfranklin,项目名称:zmake,代码行数:88,代码来源:permute.cpp

示例3: pop

 static void pop(std::stack<T>& stk) {
     stk.pop();
 }
开发者ID:rberrens,项目名称:piPipes,代码行数:3,代码来源:generic_container.hpp

示例4: loadIdentity

inline void GLMatrixStack::loadIdentity() {
   matricies_.pop();
   matricies_.push(glm::mat4());   
}
开发者ID:dcbishop,项目名称:cppcollada,代码行数:4,代码来源:GLMatrixStack.hpp

示例5: endElement

    void endElement(void *ctx, const char *name)
    {
        CC_UNUSED_PARAM(ctx);
        SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top();
        const std::string sName((char*)name);
        if( sName == "dict" )
        {
            _stateStack.pop();
            _dictStack.pop();
            if ( !_dictStack.empty())
            {
                _curDict = _dictStack.top();
            }
        }
        else if (sName == "array")
        {
            _stateStack.pop();
            _arrayStack.pop();
            if (! _arrayStack.empty())
            {
                _curArray = _arrayStack.top();
            }
        }
        else if (sName == "true")
        {
            if (SAX_ARRAY == curState)
            {
                _curArray->push_back(Value(true));
            }
            else if (SAX_DICT == curState)
            {
                (*_curDict)[_curKey] = Value(true);
            }
        }
        else if (sName == "false")
        {
            if (SAX_ARRAY == curState)
            {
                _curArray->push_back(Value(false));
            }
            else if (SAX_DICT == curState)
            {
                (*_curDict)[_curKey] = Value(false);
            }
        }
        else if (sName == "string" || sName == "integer" || sName == "real")
        {
            if (SAX_ARRAY == curState)
            {
                if (sName == "string")
                    _curArray->push_back(Value(_curValue));
                else if (sName == "integer")
                    _curArray->push_back(Value(atoi(_curValue.c_str())));
                else
                    _curArray->push_back(Value(atof(_curValue.c_str())));
            }
            else if (SAX_DICT == curState)
            {
                if (sName == "string")
                    (*_curDict)[_curKey] = Value(_curValue);
                else if (sName == "integer")
                    (*_curDict)[_curKey] = Value(atoi(_curValue.c_str()));
                else
                    (*_curDict)[_curKey] = Value(atof(_curValue.c_str()));
            }

            _curValue.clear();
        }
        
        _state = SAX_NONE;
    }
开发者ID:lmskater,项目名称:cocos2d-x,代码行数:71,代码来源:CCFileUtils.cpp

示例6: toc

 double toc() {
     double outval = GetTimestampNow() / 1000000.0 - tictoc_wall_stack.top();
     tictoc_wall_stack.pop();
     return outval;
 }
开发者ID:1ee7,项目名称:flight,代码行数:5,代码来源:tests.cpp

示例7: DeserializeValue


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

				has_dot = true;
			}
			else if ((str[i] == 'e') || (str[i] == 'E'))
			{		
				if ((_stricmp(temp_val.c_str(), "fals") != 0) && (_stricmp(temp_val.c_str(), "tru") != 0))
				{
					// it's not a boolean, check for scientific notation validity. This will also trap booleans with extra 'e' characters like falsee/truee
					if (!found_digit)
					{
						// As per JSON standards, a digit must precede the 'e' notation
						*had_error = true;
						return Value();
					}
					else if (has_e)
					{
						// multiple 'e' characters not allowed
						*had_error = true;
						return Value();
					}

					has_e = true;
				}
			}
			else if (str[i] == ']')
			{
				if (depth_stack.empty() || (depth_stack.top() != InArray))
				{
					*had_error = true;
					return Value();
				}
				
				depth_stack.pop();
			}
			else if (str[i] == '}')
			{
				if (depth_stack.empty() || (depth_stack.top() != InObject))
				{
					*had_error = true;
					return Value();
				}
				
				depth_stack.pop();
			}
			else if (str[i] == ',')
				break;			
			else if ((str[i] == '[') || (str[i] == '{'))
			{
				// error, we're supposed to be processing things besides arrays/objects in here
				*had_error = true;
				return Value();
			}

			if (!std::isspace(str[i]))
			{
				if (std::isdigit(str[i]))
					found_digit = true;

				found_first_valid_char = true;
				temp_val += str[i];
			}
		}

		// store all floating point as doubles. This will also set the float and int values as well.
		if (_stricmp(temp_val.c_str(), "true") == 0)
开发者ID:ADTRAN,项目名称:ipfixcol,代码行数:67,代码来源:json.cpp

示例8: parse_item

void parse_item(std::istream &s, std::stack<json::Value *> &struct_stack)
{
	// Get the object/array:
	json::Array *arr = NULL;
	json::Object *obj = NULL;
	if(struct_stack.top()->type() == json::TYPE_ARRAY)
		arr = dynamic_cast<json::Array *>(struct_stack.top());
	else
		obj = dynamic_cast<json::Object *>(struct_stack.top());

	
	// See if we've reached the end:
	char c = s.peek();
	check_stream(s);
	if((arr && c == ']')
		|| (obj && c == '}'))
	{
		s.ignore();
		check_stream(s);
		struct_stack.pop();

		if(!struct_stack.empty())
		{
			eat_whitespace(s);
		}

		return;
	}

	// Check for a comma:
	if((arr && !arr->empty())
		|| (obj && !obj->empty()))
	{
		if(c != ',')
			throw json::ParseException("Expected \',\' token.");

		s.ignore();
		check_stream(s);
		eat_whitespace(s);
	}


	// Read in a key if this is an object
	std::string key;
	if(obj)
	{
		key = read_json_string_basic(s);
		eat_whitespace(s);
		if(checked_stream_get(s) != ':')
			throw json::ParseException("Expected \':\' token.");
		eat_whitespace(s);
	}


	// Read in the actual value:
	json::Value *v = NULL;
	try
	{
		v = read_json_value(s);
		if(arr)
			arr->pushBackTake(v);
		else
			obj->takeValue(key, v);
	}
	catch(...)
	{
		delete v;
		throw;
	}

	if(v->type() == json::TYPE_ARRAY
		|| v->type() == json::TYPE_OBJECT)
	{
		struct_stack.push(v);
	}

	eat_whitespace(s);
}
开发者ID:Diman4EgG,项目名称:libjson,代码行数:78,代码来源:parser.cpp

示例9: popTop

inline T popTop(std::stack<T> &s) {
  T result = s.top();
  s.pop();
  return result;
}
开发者ID:Mygod,项目名称:CppExerciseCalculator,代码行数:5,代码来源:utils.hpp

示例10: endElementHandler

void ZLResourceTreeReader::endElementHandler(const char *tag) {
	if (!myStack.empty() && (NODE == tag)) {
		myStack.pop();
	}
}
开发者ID:ALEXGUOQ,项目名称:FBReader,代码行数:5,代码来源:ZLResource.cpp

示例11: dfs_search

int IterativeDeepening::dfs_search(LiteState& current, int& bound, std::stack<LiteState>& path, Timer& timer) {
	
    if(!timer.is_still_valid()){
        return current.get_g();
    }
	
	// Perform heuristic evaluation
    double startTime = omp_get_wtime();
	int h = heuristic->calc_h(std::make_shared<LiteState>(current));
    heuristic_timer += (omp_get_wtime() - startTime);
    current.set_h(h);

	// Uses stack to trace path through state space
	path.push(current);

	// Bound check
	if (current.get_f() > bound){
        // Remove this state from the back of the vector
		path.pop();
		//path.erase(path.begin() + path.size() - 1);
		nodes_rejected++;
		int f = current.get_f();
		state_space.remove(std::shared_ptr<LiteState>(new LiteState(current)));
		return f;
	}

	if (state_space.state_is_goal(current, goals)){

		timer.stop_timing_search();
		print_steps(path);
		solved = true;

        std::cout << "Nodes generated during search: " << nodes_generated << std::endl;
        std::cout << "Nodes expanded during search: " << nodes_expanded << std::endl;

        std::cout << "Sequential search took " << timer.get_search_time() << " seconds." << std::endl;
        std::cout << "Time spent calculating heuristic: " << heuristic_timer << " seconds." << std::endl;
		
		return current.get_f();
	}

	nodes_expanded++;
	int min = Search::protect_goals;

	const std::vector<Operator>& applicable_operators = get_applicable_ops(current);

	for (std::size_t i = 0; i < applicable_operators.size(); i++) {

		const Operator& op = applicable_operators[i];

		// Generate successor state, set path cost
		LiteState child = get_successor(op, current);
		int new_g = current.get_g() + op.get_cost();
		child.set_g(new_g);

		// Check if state has been visited, if it has check if we have reached it in fewer steps (lower g value)
		if (state_space.child_is_duplicate(std::shared_ptr<LiteState>(new LiteState(child)))) {
			nodes_rejected++;
			continue;
		}

		// Record operator
		int op_id = op.get_num();
		child.set_op_id(op_id);

		nodes_generated++;

        int t = 0;
 		// Explore child node
		t = dfs_search(child, bound, path, timer);
		if (t < min){
			min = t;
		}
		// Get out of recursion when done. 
		if (solved){
			break;
		}
	}
	// We have generated no children that have lead to a solution and are backtracking.
	// Erase node as we backtrack through state space
	path.pop();
	return min;
}
开发者ID:miken22,项目名称:ParallelPlanner,代码行数:83,代码来源:IterativeDeepening.cpp

示例12: sglPopMatrix

void sglPopMatrix()
{
    ctm = transformStack.top();
    transformStack.pop();
}
开发者ID:billyue,项目名称:ccrma,代码行数:5,代码来源:sgl.cpp

示例13: main

int main()
{
    std::list<Puzzle> solutions;
    
    static std::stack<Puzzle> alternatives;
    
    char inputString[81];
    
    std::string inputPuzzle = readAndVerify(inputString);
    
    Puzzle puzzle(inputPuzzle);
    
    puzzle.generatePossibleValues();
    
    alternatives.push(puzzle);
    
    while (!alternatives.empty())
    {
        puzzle = alternatives.top();
        alternatives.pop();
        
        //decide all immediately decideable cells
        puzzle.decideCells();
        
        //try simplification strats
        bool simplificationFound = true;
        while (!puzzle.solved() && simplificationFound)
        {
            simplificationFound = false;
            do
            {
                simplificationFound = hiddenSingles(puzzle);
            }
            while (simplificationFound == true);
            
            //fall back to guessing
            if (!simplificationFound)
            {
                Puzzle alternative;
                alternative = *clone(puzzle);
                if ((simplificationFound = guess(puzzle, alternative)))
                {
                    //record alternative if guess is wrong
                    alternatives.push(alternative);
                }
            }
            
            //decide all immediately decidable cells before looking for further simplifications
            if (simplificationFound)
            {
                puzzle.decideCells();
            }
        }
        
        
        //if solution is found or contradiction is found(no simplifications)
        if (puzzle.solved())
        {
            solutions.push_back(puzzle);
        }
    }
    
    if (solutions.empty())
    {
        std::cout << "No solutions.\n";
    }
    
    if (!solutions. empty())
    {
        while (!solutions.empty())
        {
            solutions.front().printPuzzle();
            solutions.pop_front();
        }
    }
    
    std::exit(0);
    
}//end main
开发者ID:zbr19583,项目名称:SudokuSolver,代码行数:79,代码来源:main.cpp

示例14: mvPopMatrix

//Pop
void mvPopMatrix(){
    model_view.pop();
}
开发者ID:ndahlquist,项目名称:nautilus,代码行数:4,代码来源:transform.cpp

示例15: call_terms

void STACK_ARGS call_terms (void)
{
	while (!TermFuncs.empty())
		TermFuncs.top().first(), TermFuncs.pop();
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:5,代码来源:i_main.cpp


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