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


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

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


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

示例1: createDependentArticles

void DepotSerializer::createDependentArticles(Article::ArticlePtr &article, const YAML::Node &article_node, std::map<int, YAML::Node> &all_articles)
{
  if (article_node["dependents"])
  {
    for (const auto & dependent_article_id : article_node["dependents"])
    {
      const auto dependentArticleId = dependent_article_id.as<int>();
      const auto & dependent_article_node = all_articles.at(dependentArticleId);
      auto dependent_article = article->createDependentArticle(dependent_article_node["name"].as< std::string>(), dependent_article_node["unit"].as<std::string>());
      deserializationArticles[dependentArticleId] = dependent_article;
      createDependentArticles(dependent_article, dependent_article_node, all_articles);
      all_articles.erase(dependent_article_id.as<int>());
    }
  }
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例2: Search

void PNSearch::Search(const PNSParams& pns_params, PNSResult* pns_result) {
  if (pns_tree_) {
    Delete(pns_tree_);
    pns_tree_ = nullptr;
  }
  pns_tree_ = new PNSNode;

  Pns(pns_params, pns_tree_);
  pns_result->pns_tree = pns_tree_;
  pns_result->tree_size = pns_tree_->tree_size;

  for (PNSNode* pns_node : pns_tree_->children) {
    // This is from the current playing side perspective.
    double score;
    int result;
    if (pns_node->proof == 0) {
      score = DBL_MAX;
      result = -WIN;
    } else {
      score = static_cast<double>(pns_node->disproof) / pns_node->proof;
      if (pns_node->proof == INF_NODES && pns_node->disproof == 0) {
        result = WIN;
      } else if (pns_node->proof == INF_NODES &&
                 pns_node->disproof == INF_NODES) {
        result = DRAW;
      } else {
        result = UNKNOWN;
      }
    }
    pns_result->ordered_moves.push_back(
        {pns_node->move, score, pns_node->tree_size, result});
  }
  sort(pns_result->ordered_moves.begin(), pns_result->ordered_moves.end(),
       [](const PNSResult::MoveStat& a, const PNSResult::MoveStat& b) {
         return a.score < b.score;
       });
  // Print the ordered moves.
  if (!pns_params.quiet) {
    std::cout << "# Move, score, tree_size:" << std::endl;
    for (const auto& move_stat : pns_result->ordered_moves) {
      static std::map<int, std::string> result_map = {
          {WIN, "WIN"}, {-WIN, "LOSS"}, {DRAW, "DRAW"}, {UNKNOWN, "UNKNOWN"}};
      std::cout << "# " << move_stat.move.str() << ", " << move_stat.score
                << ", " << move_stat.tree_size << ", "
                << result_map.at(move_stat.result) << std::endl;
    }
  }
}
开发者ID:goutham,项目名称:nakshatra,代码行数:48,代码来源:pn_search.cpp

示例3: dmiBitFieldToStr

std::string dmiBitFieldToStr(size_t bitField,
                             const std::map<uint8_t, std::string>& table) {
  std::string result;

  for (uint8_t i = 0; i < table.size(); i++) {
    if (1 << i & bitField) {
      result = result + table.at(i) + ' ';
    }
  }

  if (!result.empty()) {
    result.pop_back();
  }

  return result;
}
开发者ID:theopolis,项目名称:osquery,代码行数:16,代码来源:smbios_utils.cpp

示例4: inform_fires_and_set_mood

/** Inform Leafy of the number of fires. 
 For each config::leafy_mood_change_rate increment of fires, the
 mood of Leafy changes.
 @param number_of_fires 
 
 TODO: change to receive the vector of fires and make mood
 a function of the distance from fires.
 */
void Leafy::inform_fires_and_set_mood(const unsigned number_of_fires)
{
    Leafymood mood = static_cast<Leafymood>(number_of_fires / config::leafy_mood_change_rate);
    if (mood>skeleton) mood = skeleton;
    if(mood!=_mood)
    try {
        _mood = mood;
        set_texture(leafy_mood_filenames.at(mood));
    }
    catch(std::out_of_range &e)
    {
        /* The flow reaches this point if mood is greater than skeleton.
        */
        cocos2d::log("Leafy::inform_fires_and_set_mood(): %s", e.what());
    }
}
开发者ID:fertesta,项目名称:bobtheblobandthefires,代码行数:24,代码来源:CharacterLeafy.cpp

示例5: GetPtr

void *LibMgr::OpenLibHandle(Library lib)
{
	void *ptr = GetPtr(lib);
	
	MEMORY_BASIC_INFORMATION mem;
	if (VirtualQuery(ptr, &mem, sizeof(mem)) == 0) {
		char err[4096];
		libsys->GetPlatformError(err, sizeof(err));
		
		DevMsg("LibMgr::OpenLibHandle: can't find library \"%s\" in memory\n"
			"VirtualQuery error:\n%s\n", libnames.at(lib), err);
		return nullptr;
	}
	
	return mem.AllocationBase;
}
开发者ID:sigsegv-mvm,项目名称:sigsegv-mvm,代码行数:16,代码来源:library.cpp

示例6: getReferenceAttribute

T SceneDescription::getReferenceAttribute(
	const tinyxml2::XMLElement* node,
	const char* attributeName,
	const std::map<std::string, T>& map)
{
	std::string attr = getAttribute(node, attributeName);
	if (map.find(attr) == map.end())
	{
		throw SceneDescriptionException(
			"This '" + std::string(node->Name()) + "' node's '" + std::string(attributeName) +
			"' attribute has a value of '" + attr +
			"', but no appropriate element could be found for '" + attr + "'.");
	}

	return map.at(attr);
}
开发者ID:jonathanvdc,项目名称:space-invaders,代码行数:16,代码来源:SceneDescription.cpp

示例7: GetAccumulatorValueFromChecksum

bool GetAccumulatorValueFromChecksum(uint32_t nChecksum, bool fMemoryOnly, CBigNum& bnAccValue)
{
    if (mapAccumulatorValues.count(nChecksum)) {
        bnAccValue = mapAccumulatorValues.at(nChecksum);
        return true;
    }

    if (fMemoryOnly)
        return false;

    if (!zerocoinDB->ReadAccumulatorValue(nChecksum, bnAccValue)) {
        bnAccValue = 0;
    }

    return true;
}
开发者ID:michaili,项目名称:PIVX,代码行数:16,代码来源:accumulators.cpp

示例8: getDataRoutine

SISCAT::RETURN::Return_t Ruler::getData(
		const std::map<std::string, std::string>& param, std::string& result)
{
	if(m_MidLevel == 0)
	{
		ReadMidLevel();
	}
	if (param.find("RULER_PIN_NUMBERS") == param.end())
	{
		return SISCAT::RETURN::PARAMETRO_INVALIDO;
	}
	std::string numMaxPin;
	numMaxPin = param.at("RULER_PIN_NUMBERS");

	return getDataRoutine(atoi(numMaxPin.c_str()), result);;
}
开发者ID:anonspacecowboy,项目名称:DummyRep,代码行数:16,代码来源:rule.cpp

示例9: addNode

ResidualGraph::ResidualGraph(
		const Graph& original, 
		const OriginalNode& origSource, 
		const std::map<OriginalNode, size_t>& nodeTimestepMap, 
		bool useBackArcs,
		bool useOrderedNodeListInBF
):
	originalGraph_(original),
	useBackArcs_(useBackArcs),
	useOrderedNodeListInBF_(useOrderedNodeListInBF),
	residualDistMap_(*this),
	nodeUpdateOrderMap_(*this),
	bfDistMap_(*this),
	bfPredMap_(*this),
	bf(*this, residualDistMap_, bfProcess_, bfNextProcess_),
	firstPath_(true)
{
	reserveNode(lemon::countNodes(original));
	reserveArc(2 * lemon::countArcs(original));

	for(Graph::NodeIt origNode(original); origNode != lemon::INVALID; ++origNode)
	{
		Node n = addNode();
		originMap_[n] = origNode;
		residualNodeMap_[origNode] = n;
		nodeUpdateOrderMap_.set(n, nodeTimestepMap.at(origNode));
	}

	for(Graph::ArcIt origArc(original); origArc != lemon::INVALID; ++origArc)
	{
		residualArcProvidesTokens_[arcToPair(origArc)] = {};
		residualArcProvidesTokens_[arcToInversePair(origArc)] = {};
		residualArcForbidsTokens_[arcToPair(origArc)] = {};
		residualArcForbidsTokens_[arcToInversePair(origArc)] = {};
		residualArcMap_[arcToPair(origArc)] = ResidualArcProperties();
		residualArcMap_[arcToInversePair(origArc)] = ResidualArcProperties();
	}

	bfProcess_.reserve(lemon::countNodes(*this));
	bfNextProcess_.reserve(lemon::countNodes(*this));
	dirtyNodes_.reserve(lemon::countNodes(*this));

    bf.distMap(bfDistMap_);
    bf.predMap(bfPredMap_);
    source_ = residualNodeMap_.at(origSource);
}
开发者ID:chaubold,项目名称:dpct,代码行数:46,代码来源:residualgraph.cpp

示例10:

const std::vector<std::string>&
getVehicleClassNamesList(SVCPermissions permissions) {
    // first check if it's cached
    if (vehicleClassNamesListCached.count(permissions) == 0) {
        const std::vector<std::string> classNames = SumoVehicleClassStrings.getStrings();
        std::vector<std::string> result;
        for (std::vector<std::string>::const_iterator it = classNames.begin(); it != classNames.end(); it++) {
            const int svc = (int)SumoVehicleClassStrings.get(*it);
            if ((svc & permissions) == svc && svc != SVC_IGNORING) {
                result.push_back(*it);
            }
        }
        // add it into vehicleClassNamesListCached
        vehicleClassNamesListCached[permissions] = result;
    }
    return vehicleClassNamesListCached.at(permissions);
}
开发者ID:michele-segata,项目名称:plexe-sumo,代码行数:17,代码来源:SUMOVehicleClass.cpp

示例11: return

bu_ptr
parse_note(PyObject * seq, double duration)
{
    if ( ! PyTuple_Check(seq)) throw std::runtime_error("note isn't Tuple");
    const int n = PyTuple_Size(seq);
    int i = 0;
    if (n == 0) throw std::runtime_error("note Tuple empty");
    PyObject * head = PyTuple_GetItem(seq, 0);
    if (PyNumber_Check(head)) {
        if (duration != 0) throw std::runtime_error("duration over-ridden");
        duration = tempo * parse_float(head);
        ++i;
    }
    if (i + 2 != n) throw std::runtime_error("note Tuple size invalid");
    std::string label = parse_string(PyTuple_GetItem(seq, i++));
    return (*orchestra.at(label))(duration, PyTuple_GetItem(seq, i++));
}
开发者ID:biotty,项目名称:rmg,代码行数:17,代码来源:lib.cpp

示例12: addToMap

void addToMap( Vector4D key, 
                Vector3D value , 
                std::map<Vector4D, std::vector<Vector3D>*, vec4Compare> &vertexNormals)
{
    std::vector<Vector3D>* valueArray;
	try
	{
		valueArray = vertexNormals.at( key );
		valueArray->push_back( value );
	}
	catch(const std::out_of_range& e) 
	{
		valueArray = new std::vector<Vector3D>();
		valueArray->push_back( value );
		vertexNormals.insert( std::pair<Vector4D, std::vector<Vector3D>*>(key, valueArray) );
	}
}
开发者ID:psarahdactyl,项目名称:CGpractice,代码行数:17,代码来源:SMFModel.cpp

示例13: flex_type_enum_from_name

/**
 * \ingroup group_gl_flexible_type
 * Given the printable name of a flexible_type type, returns its corresponding
 * \ref flex_type_enum enumeration value.
 * Reverse of \ref flex_type_enum_to_name.
 */
inline flex_type_enum flex_type_enum_from_name(const std::string& name) {
  static std::map<std::string, flex_type_enum> type_map{
    {"integer", flex_type_enum::INTEGER},
    {"datetime", flex_type_enum::DATETIME},
    {"float", flex_type_enum::FLOAT},
    {"string", flex_type_enum::STRING},
    {"array", flex_type_enum::VECTOR},
    {"recursive", flex_type_enum::LIST},
    {"dictionary", flex_type_enum::DICT},
    {"image", flex_type_enum::IMAGE},
    {"undefined", flex_type_enum::UNDEFINED}
  };
  if (type_map.count(name) == 0) {
    log_and_throw(std::string("Invalid flexible type name " + name));
  }
  return type_map.at(name);
}
开发者ID:OspreyX,项目名称:GraphLab-Create-SDK,代码行数:23,代码来源:flexible_type_base_types.hpp

示例14: startScraperSearch

std::unique_ptr<ScraperSearchHandle> startScraperSearch(const ScraperSearchParams& params)
{
	const std::string& name = Settings::getInstance()->getString("Scraper");
	std::unique_ptr<ScraperSearchHandle> handle(new ScraperSearchHandle());

	// Check if the Scraper in the settings still exists as a registered scraping source.
	if (scraper_request_funcs.find(name) == scraper_request_funcs.end())
	{
		LOG(LogWarning) << "Configured scraper (" << name << ") unavailable, scraping aborted.";
	}
	else
	{
		scraper_request_funcs.at(name)(params, handle->mRequestQueue, handle->mResults);
	}

	return handle;
}
开发者ID:RetroPie,项目名称:EmulationStation,代码行数:17,代码来源:Scraper.cpp

示例15: parseUserOptions

static void parseUserOptions(int argc, char *argv[],
                             struct user_req &req,
                             po::variables_map &vm)
{
    parseCommandOptions(argc, argv, getUserOptions(), vm);
    try {
        if (vm.count("uid"))
            req.uid = vm["uid"].as<uid_t>();
        if (vm.count("usertype")){
            req.utype = user_type_map.at(vm["usertype"].as<std::string>());
        } else
            req.utype = SM_USER_TYPE_NORMAL;
    } catch (const std::out_of_range &e) {
        po::error er("Invalid user type found.");
        throw er;
    }
}
开发者ID:Samsung,项目名称:security-manager,代码行数:17,代码来源:security-manager-cmd.cpp


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