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


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

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


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

示例1: compute

 void compute(stack<int>& operands, stack<char>& operators) {
     const int left = operands.top();
     operands.pop();
     const int right = operands.top();
     operands.pop();
     const char op = operators.top();
     operators.pop();
     if (op == '+') {
         operands.emplace(left + right);
     } else if (op == '-') {
         operands.emplace(left - right);
     }
 } 
开发者ID:1461190388,项目名称:LeetCode,代码行数:13,代码来源:basic-calculator.cpp

示例2: compute

 void compute(stack<int>& operands, stack<string>& operators) {
     const int left = operands.top();
     operands.pop();
     const int right = operands.top();
     operands.pop();
     const string op = operators.top();
     operators.pop();
     if (op == "+") {
         operands.emplace(left + right);
     } else if (op == "-") {
         operands.emplace(left - right);
     } else if (op == "*") {
         operands.emplace(left * right);
     } else if (op == "/") {
         operands.emplace(left / right);
     }
 }
开发者ID:HaochenLiu,项目名称:My-LintCode-CPP,代码行数:17,代码来源:368.cpp

示例3: DFS

void DFS(GraphVertex* cur, stack<GraphVertex*> &vertex_order) {
  cur->visited = true;
  for (GraphVertex* &next : cur->edges) {
    if (next->visited == false) {
      DFS(next, vertex_order);
    }
  }
  vertex_order.emplace(cur);
}
开发者ID:lc2879,项目名称:Ccode,代码行数:9,代码来源:Team_photo_2.cpp

示例4:

static void
entry(const string &type)
{
#ifdef DEBUG
    types.push(type);
    recognition.emplace();
    if (unrecognized.count(type) == 0) {
        unrecognized[type] = set<string>();
    }
#endif
}
开发者ID:dmpas,项目名称:v81cformat,代码行数:11,代码来源:serializer.cpp

示例5: delete

    void operator delete(void* pMem)
    {
        lock_guard<mutex> lock{ s_Mutex };

        const int index{
            (static_cast<MyManagedObject*>(pMem)-s_ManagedObjects.data()) /
            static_cast<intptr_t>(sizeof(MyManagedObject)) };
        if (0 <= index && index < static_cast<int>(s_ManagedObjects.size()))
        {
            s_FreeList.emplace(static_cast<unsigned int>(index));
        }
        else
        {
            free(pMem);
        }
    }
开发者ID:copley,项目名称:CPP_Recipes_A_Problem_Solution_Approach_Training,代码行数:16,代码来源:main.cpp

示例6: produce

/// Produce \c element_count foos.
void produce(size_t element_count, size_t id_offset, stack& foos)
{
    size_t id = id_offset;

    {
        lock_guard<mutex> _(g_io_mutex);
        cout << this_thread::get_id() << " - produce from ID " << id << endl;
    }

    for (size_t i = 0; i < element_count; ++i) {
        foos.emplace(foo(id++));
    }

    {
        lock_guard<mutex> _(g_io_mutex);
        cout << this_thread::get_id() << " - produced to ID " << id << endl;
    }
}
开发者ID:migrantcoder,项目名称:Mu,代码行数:19,代码来源:stack.cpp

示例7: expandNextNode

void Node::expandNextNode(stack<Node>& fringe)
{
	auto x = get<0>(nextNodeMove);
	auto y = get<1>(nextNodeMove);

	// Has this function call already expanded a node.
	// We need to keep track of this so that we can increment nextNodeMove
	// until it points to the next valid move.
	auto expanded = false;

	for (/* y */; y < 3; ++y)
	{
		for (/* first init x as stored value, then 0 */ ; x < 3; ++x)
		{
			if (state->isFree(x, y))
			{
				if (!expanded)
				{
					// Add child state to the fringe
					auto newBoard = make_unique<GameBoard>(*state);
					auto newMove = make_unique<Move>(x, y);
					newBoard->makeMove(*newMove);
					fringe.emplace(Node{move(newBoard), this,
						move(newMove), depth > 0 ? depth - 1 : 0,
						alpha, beta, !maximizer});
					expanded = true; // Only expand once per function call
				}
				else
				{
					// Save the coordinates of the next free space
					nextNodeMove = decltype(nextNodeMove){ x, y };
					return;
				}
			}
		}
		x = 0; // On a new row, so reset x to 0
	}

	// No more nodes found, so indicate that with an invalid move
	nextNodeMove = decltype(nextNodeMove){ 3, 3 };
}
开发者ID:derekrfelson,项目名称:tic-tac-toe-solver,代码行数:41,代码来源:Node.cpp

示例8: push

 void push(const T &x) {
   s.emplace(x, std::max(x, empty() ? x : s.top().second));
 }
开发者ID:lc2879,项目名称:Ccode,代码行数:3,代码来源:Queue_with_max.cpp

示例9: push

 void push(int x) {
     int minVal = d_stack.empty() ? x : min(x, d_stack.top().second);
     d_stack.emplace(x, minVal);
 }
开发者ID:kyliau,项目名称:playground,代码行数:4,代码来源:MinStack.cpp


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