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; } }
void emplace(Args&&... args) { bool empty_ = empty(); internal.emplace(std::forward<Args>(args)...); if (empty_) not_empty.notify_all(); }
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; }
// 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; } }
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); } }
void emplace(Args&&... args) { return q.emplace(std::forward<Args>(args)...); }
void RecreatorImpl::push(const std::string &operand) { stack.emplace(operand, Precedence::Operand); }
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); }
Game() { history = std::stack<State>(); history.emplace(); }
bool Key(const char* str, SizeType length, bool copy) { stack.emplace(stack.top()->key({str, (size_t)length})); return true; }
inline void setCategory(Category& mCategory) { lastCategories.emplace(&mCategory); category = &mCategory; }
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); } } } } }