本文整理汇总了C++中std::stack::emplace方法的典型用法代码示例。如果您正苦于以下问题:C++ stack::emplace方法的具体用法?C++ stack::emplace怎么用?C++ stack::emplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::stack
的用法示例。
在下文中一共展示了stack::emplace方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: emplace
void emplace(Args&&... args)
{
bool empty_ = empty();
internal.emplace(std::forward<Args>(args)...);
if (empty_)
not_empty.notify_all();
}
示例3: main
int main(int argc, char* argv[])
{
for (int i = 10; i > 0; --i) {
A.emplace(i);
}
Dump("init", 0);
HanoiTowerMoveN(A.size(), A, B, C);
return 0;
}
示例4:
// TraialPool::get_traials() specialization for STL std::stack<>
template<> void
TraialPool::get_traials(std::stack< Reference<Traial> >& stack,
unsigned numTraials)
{
assert(0u < numTraials);
numTraials++; // loop guard condition requires this increment
retrieve_traials:
while (!available_traials_.empty() && 0u < --numTraials) {
stack.emplace(available_traials_.front());
available_traials_.pop_front();
}
if (0u < numTraials) {
ensure_resources(std::max<unsigned>(numTraials++, sizeChunkIncrement));
goto retrieve_traials;
}
}
示例5: HanoiTowerMoveN
void HanoiTowerMoveN(int n, std::stack<int>& from, std::stack<int>& to, std::stack<int>& tmp)
{
assert(n >= 1);
if (n == 1) {
if (to.empty() || to.top() > from.top()) {
to.emplace(from.top());
from.pop();
}
}
else {
HanoiTowerMoveN(n - 1, from, tmp, to);
Dump("(a)", n - 1);
HanoiTowerMoveN(1, from, to, tmp);
Dump("(b)", 1);
HanoiTowerMoveN(n - 1, tmp, to, from);
Dump("(c)", n - 1);
}
}
示例6: emplace
void emplace(Args&&... args) {
return q.emplace(std::forward<Args>(args)...);
}
示例7: push
void RecreatorImpl::push(const std::string &operand)
{
stack.emplace(operand, Precedence::Operand);
}
示例8: setboard
void setboard(std::string fen) {
// not sure about when setboard will be called. assuming after "new"
// and before anything that modifies the state.
history = std::stack<State>();
history.emplace(fen);
}
示例9: Game
Game() {
history = std::stack<State>();
history.emplace();
}
示例10: Key
bool Key(const char* str, SizeType length, bool copy)
{
stack.emplace(stack.top()->key({str, (size_t)length}));
return true;
}
示例11: setCategory
inline void setCategory(Category& mCategory)
{
lastCategories.emplace(&mCategory);
category = &mCategory;
}
示例12: if
void algorithms::KDDecomposer<IROBOT>::DecomposeSubspaces(std::stack<int>& stack, double large_radius, double min_radius, std::unordered_map<int, double>& impt_map)
{
while (!stack.empty())
{
int node_index = stack.top();
stack.pop();
double cell_radius = radius_array[get_node(node_index).depth()];
// 3R Arm:
//double local_min_radius = std::min( large_radius/2.0, std::max(min_radius, large_radius/(impt_map[node_index]*10)));
// 4R Arm:
double local_min_radius = std::min( large_radius/2.0, std::max(min_radius, large_radius/(impt_map[node_index])));
robot_.set_config(get_node(node_index).center());
double dist_to_obsts = obstacle_manager_.dist_to_obsts(robot_);
if (dist_to_obsts > 0)
{
get_node(node_index).reset_info();
// Create free space ball
double initial_guess = CalcFreeCellRadius(dist_to_obsts);
double radius = robot_.free_space_oracle(obstacle_manager_, initial_guess /* lower bound */, 2 * initial_guess /* upper bound */);
if (robot_.subconvex_radius(obstacle_manager_, radius, cell_radius))
{
get_node(node_index).set_covered();
get_node(node_index).set_free();
if (!MERGE_CELLS)
get_node(node_index).set_cell(get_new_cell(get_node(node_index).center(), cell_radius, node_index));
}
else if( cell_radius > local_min_radius )
{
get_node(node_index).set_children( NOT_FOUND );
SplitCell(node_index);
for (int i = 0; i < NUM_SPLITS; ++i)
{
impt_map[get_node(node_index).get_children()+i] = impt_map[node_index];
stack.emplace(get_node(node_index).get_children()+i);
}
}
}
else
{
get_node(node_index).reset_info();
const double penetration = obstacle_manager_.penetration(robot_);
if ( penetration / robot_.get_max_speed() >= (PENETRATION_CONSTANT / min_param_speed_) * cell_radius )
{
continue;
}
else if (cell_radius > local_min_radius )
{
get_node(node_index).set_children( NOT_FOUND );
SplitCell(node_index);
for (int i = 0; i < NUM_SPLITS; ++i)
{
impt_map[get_node(node_index).get_children() + i] = impt_map[node_index];
stack.emplace(get_node(node_index).get_children() + i);
}
}
}
}
}