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


C++ map::at方法代码示例

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


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

示例1: solution

int solution(uint goal) {
    if (min_num.count(goal) == 1) {
        return (int) min_num.at(goal).size();
    } else {
        bool f = false;
        int result = INT32_MAX;
        multiset<uint> cur_set;
        int prev_sol;
        for (auto i = values.begin(); i != values.end(); i++) {
            if (goal - *i > goal) {
                continue;
            }
            prev_sol = solution(goal - *i);
            if (prev_sol == -1) {
                continue;
            }
            if (result > 1 + prev_sol) {
                f = true;
                result = 1 + prev_sol;
                cur_set = min_num.at(goal - *i);
                cur_set.insert(*i);
            }
        }
        min_num[goal] = cur_set;
        if (f) {
            return result;
        } else {
            return -1;
        }
    }
}
开发者ID:nststnchl,项目名称:coinsProblem,代码行数:31,代码来源:main.cpp

示例2: main

int main()
{
    use_io_optimizations();

    unsigned int test_cases;
    cin >> test_cases;
    cin.ignore();

    for (unsigned int test {1}; test <= test_cases; ++test)
    {
        cout << "Case #" << test << ": ";

        string message;
        getline(cin, message);

        for (auto i = message.cbegin(); i != message.cend(); ++i)
        {
            if (i != message.cbegin() && buttons.at(*i) == buttons.at(*(i - 1)))
            {
                cout << ' ';
            }

            cout << string(presses.at(*i), buttons.at(*i));
        }

        cout << '\n';
    }

    return 0;
}
开发者ID:Rishi51199,项目名称:Kattis,代码行数:30,代码来源:t9_spelling.cpp

示例3: findExclusiveGroups

static
map<u32, set<u32>> findExclusiveGroups(const RoseBuildImpl &build,
            const map<u32, unordered_set<u32>> &exclusiveInfo,
            const map<u32, vector<RoseVertex>> &vertex_map,
            const bool is_infix) {
    map<u32, set<u32>> exclusiveGroups;
    for (const auto &e : exclusiveInfo) {
        u32 i = e.first;
        const auto &s = e.second;
        set<u32> group;
        set<RoseVertex> q1(vertex_map.at(i).begin(),
                           vertex_map.at(i).end());
        DEBUG_PRINTF("vertex set:%zu\n", q1.size());
        for (const auto &val : s) {
            set<RoseVertex> q2(vertex_map.at(val).begin(),
                               vertex_map.at(val).end());
            if (contains(exclusiveInfo.at(val), i) &&
                (!is_infix || mergeableRoseVertices(build, q1, q2))) {
                group.insert(val);
            }
        }
        if (!group.empty()) {
            exclusiveGroups[i] = group;
        }
    }

    return exclusiveGroups;
}
开发者ID:tomzhang,项目名称:hyperscan,代码行数:28,代码来源:rose_build_exclusive.cpp

示例4: mouseFunc

void mouseFunc(int button, int state, int _x , int _y)
{
    if ( trialMode!=PROBEMODE || !canCalibrate )
        return;
    if ( button== GLUT_LEFT_BUTTON && canCalibrate )
    {
        response=true;
    }

    if (button == GLUT_RIGHT_BUTTON && canCalibrate )
    {
        response=false;
    }

    responseFile <<
                 trialNumber << "\t" <<
                 factors.at("Tilt") << "\t" <<
                 factors.at("Slant") << "\t" <<
                 factors.at("Binocular") << "\t" <<
                 factors.at("OmegaY") << "\t" <<
                 responseTimer.getElapsedTimeInMilliSec() << "\t" <<
                 response << endl;
    beepOk();
    factors = trial.getNext();

    trialMode=FIXATIONMODE;
    translationTimer.start();
    responseTimer.start();
    trialNumber++;
    glutPostRedisplay();
}
开发者ID:guendas,项目名称:cncsvision,代码行数:31,代码来源:expDprimeTMSoverMT.cpp

示例5: at

void TikzExporter2::export_single_snapshot_internal(ostream& output,
        const Snapshot& s,
        const task_id t,
        const map<task_id, vector<task_id>>& rt,
        const unsigned int depth,
        const float leftoffset) const{
    const float mywidth = 1.5f;
    const float myheight = 1.5f;
    const vector<task_id>& marked = s.marked;
    output << "\\node[";
    output << "circle, scale=0.75, fill";
    if(marked.size() == 0 || find(marked.begin(), marked.end(), t) != marked.end()){
        output << ", task_scheduled";
    }
    float complete_width=get_subtree_width(t, rt);
    output << "] (tid" << t << ") at (" 
        << mywidth * (leftoffset + 0.5f * complete_width) 
        << "," << myheight * depth << "){";
    if(show_labels){
        output << "\\scriptsize{" << t << "}";
    }
    output << "};" << endl;
    float cur_leftoffset = leftoffset;
    // draw "children"
    for(auto const& it : rt.at(t)){
        export_single_snapshot_internal(output, s, it, rt, depth + 1, cur_leftoffset);
        cur_leftoffset += get_subtree_width(it, rt);
    }
    // draw arrows from children
    for(auto const& it : rt.at(t)){
        output << "\\draw[](tid" << t << ") -- (tid" << it << ");" << endl;
    }
}
开发者ID:phimuemue,项目名称:tasks_time,代码行数:33,代码来源:newtikzexporter.cpp

示例6: drawTrial

void drawTrial()
{   switch ( trialMode )
    {
    case FIXATIONMODE :
    {
        // disegna le dita per debug
        if ( block.at("Phase")==1 && isDrawing==1 )
            drawFixation();
    }
    break;
    case HANDONSTARTMODE :
    {
        // disegna le dita per debug
        if ( block.at("Phase")==1 && isDrawing==1 )
            drawFingerTips();
    }
    break;
    case STIMULUSMODE:
    {
        // Disegna le dita solo durante la fase di adattamento
        if ( block.at("Phase")==1 && isDrawing==1 )
            drawFingerTips();
        drawStimulus();
    }
    break;
    }
}
开发者ID:guendas,项目名称:cncsvision,代码行数:27,代码来源:expFingerTestTSProva.cpp

示例7: setConfiguration

void Waltz::setConfiguration(map<string, int> config) {
	this->config.MaxStepsAfterWinner = config.at("MaxStepsAfterWinner");
	this->config.BatteryCapacity = config.at("BatteryCapacity");
	this->config.BatteryConsumptionRate = config.at("BatteryConsumptionRate");
	this->config.BatteryRechargeRate = config.at("BatteryRechargeRate");
	this->batteryRemianing = this->config.BatteryCapacity;
}
开发者ID:liatgrin,项目名称:R.U.M.B.A.,代码行数:7,代码来源:Waltz.cpp

示例8: addAnomalyState

void addAnomalyState(map<int, State*> & states){
	State* state = states.at(8);
	Option* option = new Option();
	option->setChoice("Watch her to see what she will do");
	option->setNextState(states.at(7));
	state->addOption(option);
}
开发者ID:Zinbo,项目名称:EternityOfTheBrokenKings,代码行数:7,代码来源:TextAdventure.cpp

示例9: getCoinCombinationsWithTargetSumDynamic

vector<vector<int>> getCoinCombinationsWithTargetSumDynamic(const set<int>& coins, int target) {

    vector<vector<int>> coin_combinations;

    for (int coin : coins) {

        int remaining_value = target - coin;

        if (remaining_value == 0) {

            coin_combinations.push_back({coin});

        } else if (remaining_value > 0) {

            if (combinations_for_target.at(remaining_value).size() > 0) {

                for (vector<int> combination : combinations_for_target.at(remaining_value)) {

                    combination.push_back(coin);
                    coin_combinations.push_back(combination);

                }

            }

        }

    }

    return coin_combinations;
}
开发者ID:Blisse,项目名称:Interviews,代码行数:31,代码来源:coins.cpp

示例10: getSIScaling

double getSIScaling(const string &originUnit, const string &destinationUnit) {
    double scaling = 1.0;
    if (!isScalable(originUnit, destinationUnit)) {
        throw nix::InvalidUnit("Origin unit and destination unit are not scalable versions of the same SI unit!",
                               "nix::util::getSIScaling");
    }
    
    string org_unit, org_prefix, org_power;
    string dest_unit, dest_prefix, dest_power;
    splitUnit(originUnit, org_prefix, org_unit, org_power);
    splitUnit(destinationUnit, dest_prefix, dest_unit, dest_power);

    if ((org_prefix == dest_prefix) && (org_power == dest_power)) {
        return scaling;
    }
    if (dest_prefix.empty() && !org_prefix.empty()) {
        scaling = PREFIX_FACTORS.at(org_prefix);
    } else if (org_prefix.empty() && !dest_prefix.empty()) {
        scaling = 1.0 / PREFIX_FACTORS.at(dest_prefix);
    } else if (!org_prefix.empty() && !dest_prefix.empty()) {
        scaling = PREFIX_FACTORS.at(org_prefix) / PREFIX_FACTORS.at(dest_prefix);
    }
    if (!org_power.empty()) {
        int power = std::stoi(org_power);
        scaling = pow(scaling, power);
    }
    return scaling;
}
开发者ID:wvangeit,项目名称:nix,代码行数:28,代码来源:util.cpp

示例11: get_tokens

void get_tokens(const string &expr) {
    stack<string> operators;
    string current_token;
    for (unsigned int i = 0; i < expr.size(); ++i) {
        // If the next char is a space or we're at the end of the expression
        if (isspace(expr[i + 1]) || i == expr.size() - 1) {
            current_token += expr[i];
            if (is_operator(current_token)) {
                // If the stack contains higher precedence tokens,
                while (!operators.empty() && precedence.at(operators.top()) >= precedence.at(current_token)) {
                    postfix.push_back(operators.top());
                    operators.pop();
                }
                operators.push(current_token);
            } else {
                postfix.push_back(current_token);
            }
            current_token = "";
        } else if (!isspace(expr[i])) {
            current_token += expr[i];
        }
    }
    // Check for remainding operators
    while(!operators.empty()) {
        postfix.push_back(operators.top());
        operators.pop();
    }
}
开发者ID:josiahcampbell,项目名称:cis452,代码行数:28,代码来源:main.cpp

示例12: diff

  map<string,double> perturb_solution_gradient(map<string,Vec4d>&targets,map<string,double>&solution)
  {
    map<string,double> sp;
    
    for(auto && param : solution)
    {        
      // data gradient
      double grad = 0;
      for(auto && target : targets)
      {
	Vec4d cur_pos = joint_position(target.first,solution);
	for(int i = 0; i < 4; ++i)
	{
	  grad += 2 * (cur_pos.values[i] - target.second.values[i]) * diff(target.first,param.first,i,solution);
	}
      }
      
      // regularizer gradient
      auto null_value = null_solution.at(param.first);	
      double C = regularizers.at(param.first);
      double diff = null_value - param.second;
      grad += C * -2 * diff;

      // update
      sp[param.first] = param.second - step_size*grad;
    }

    return sp;
  }
开发者ID:jsupancic,项目名称:libhand-public,代码行数:29,代码来源:iksolver.cpp

示例13: destructStory

void destructStory(map<int, State*> &states){
	for(int i = 1; i <= states.size(); i++){
		for(int j = 0; j < states.at(i)->getOptions().size(); j++){
			delete states.at(i)->getOptions().at(j);
		}
		delete states.at(i);
	}
}
开发者ID:Zinbo,项目名称:EternityOfTheBrokenKings,代码行数:8,代码来源:TextAdventure.cpp

示例14: stateToString

string Ram::stateToString(map<AddrSpace, vector<vector<bool>>> state) {
  string out;
  out += "# Code:\n";
  out += spaceToString(state.at(CODE));
  out += "\n# Data:\n";
  out += spaceToString(state.at(DATA));
  return out;
}
开发者ID:benmxavier,项目名称:comp-m2,代码行数:8,代码来源:ram.cpp

示例15: createPlayerArray

	RenderedMatch::RenderedMatch(IngameState& ingameState, fea::Renderer2D& renderer, PlayersColor color)
		: cyvmath::mikelepage::Match({}, false, false, createPlayerArray(color, *this)) // TODO
		, m_renderer{renderer}
		, m_ingameState{ingameState}
		, m_board(renderer, color)
		, m_gameEnded{false}
		, m_ownColor{color}
		, m_opColor{!color}
		, m_self{dynamic_cast<LocalPlayer&>(*m_players[m_ownColor])}
		, m_op{dynamic_cast<RemotePlayer&>(*m_players[m_opColor])}
		, m_setupAccepted{false}
		, m_piecePromotionBackground{{glm::vec2{100, 100}, glm::vec2{100, 100}, glm::vec2{100, 100}}}
		, m_piecePromotionTypes{{PieceType::UNDEFINED, PieceType::UNDEFINED, PieceType::UNDEFINED}}
		, m_renderPiecePromotionBgs{0}
		, m_piecePromotionHover{0}
		, m_piecePromotionMousePress{0}
	{
		// hardcoded temporarily [TODO]
		static const map<PlayersColor, Coordinate> fortressStartCoords {
			{PlayersColor::WHITE, HexCoordinate(4, 7)},
			{PlayersColor::BLACK, HexCoordinate(6, 3)}
		};

		auto ownFortress = make_unique<RenderedFortress>(m_ownColor, fortressStartCoords.at(m_ownColor), m_board);
		m_renderedEntities[RenderPriority::FORTRESS].push_back(ownFortress->getQuad());

		m_self.setFortress(move(ownFortress));
		m_op.setFortress(make_unique<RenderedFortress>(m_opColor, fortressStartCoords.at(m_opColor), m_board));

		glm::uvec2 boardSize = m_board.getSize();
		glm::uvec2 boardPos = m_board.getPosition();

		auto tmpTexture = makeTexture("res/setup-done.png");

		m_buttonSetupDoneTexture = move(tmpTexture.first);
		m_buttonSetupDone.setPosition(boardPos + boardSize - tmpTexture.second);
		m_buttonSetupDone.setSize(tmpTexture.second); // hardcoded for now, can be done properly somewhen else
		m_buttonSetupDone.setTexture(m_buttonSetupDoneTexture);

		for (auto& quad : m_piecePromotionBackground)
			quad.setColor({95, 95, 95});

		placePiecesSetup();

		ingameState.tick                  = bind(&RenderedMatch::tick, this);
		ingameState.onMouseMoved          = bind(&Board::onMouseMoved, &m_board, _1);
		ingameState.onMouseButtonPressed  = bind(&Board::onMouseButtonPressed, &m_board, _1);
		ingameState.onMouseButtonReleased = bind(&Board::onMouseButtonReleased, &m_board, _1);
		ingameState.onKeyPressed          = [](const fea::Event::KeyEvent&) { };
		ingameState.onKeyReleased         = [](const fea::Event::KeyEvent&) { };

		m_board.onTileMouseOver    = bind(&RenderedMatch::onTileMouseOver, this, _1);
		m_board.onTileClicked      = bind(&RenderedMatch::onTileClicked, this, _1);
		m_board.onMouseMoveOutside = bind(&RenderedMatch::onMouseMoveOutside, this, _1);
		m_board.onClickedOutside   = bind(&RenderedMatch::onClickedOutsideBoard, this, _1);

		setStatus("Setup");
	}
开发者ID:cyvasse-online,项目名称:game-old,代码行数:58,代码来源:rendered_match.cpp


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