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


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

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


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

示例1: move

std::unordered_map<T, std::pair<U, V>> zip(const std::unordered_map<T, U>& a, const std::unordered_map<T, V>& b) {
    assert(a.size() == b.size());
    std::unordered_map<T, std::pair<U, V>> c;
    for (const auto& e : a)
        c[e.first] = std::make_pair(a.at(e.first), b.at(e.first));
    return std::move(c);
}
开发者ID:etano,项目名称:free_fermions,代码行数:7,代码来源:function.hpp

示例2: cellVideoOutGetState

error_code cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideoOutState> state)
{
	cellSysutil.trace("cellVideoOutGetState(videoOut=%d, deviceIndex=%d, state=*0x%x)", videoOut, deviceIndex, state);

	if (deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;

	switch (videoOut)
	{
	case CELL_VIDEO_OUT_PRIMARY:
		state->state = CELL_VIDEO_OUT_OUTPUT_STATE_ENABLED;
		state->colorSpace = CELL_VIDEO_OUT_COLOR_SPACE_RGB;
		state->displayMode.resolutionId = g_video_out_resolution_id.at(g_cfg.video.resolution); // TODO
		state->displayMode.scanMode = CELL_VIDEO_OUT_SCAN_MODE_PROGRESSIVE;
		state->displayMode.conversion = CELL_VIDEO_OUT_DISPLAY_CONVERSION_NONE;
		state->displayMode.aspect = g_video_out_aspect_id.at(g_cfg.video.aspect_ratio); // TODO
		state->displayMode.refreshRates = CELL_VIDEO_OUT_REFRESH_RATE_59_94HZ;
		return CELL_OK;

	case CELL_VIDEO_OUT_SECONDARY:
		*state = { CELL_VIDEO_OUT_OUTPUT_STATE_DISABLED }; // ???
		return CELL_OK;
	}

	return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
开发者ID:cornytrace,项目名称:rpcs3,代码行数:25,代码来源:cellVideoOut.cpp

示例3: genReadComparisonGraph

ReadCompGraph genReadComparisonGraph(const std::vector<T> & reads,
		aligner & alignerObj,
		std::unordered_map<std::string, std::unique_ptr<aligner>>& aligners,
		std::mutex & alignerLock, uint32_t numThreads) {
	std::function<
			comparison(const T &, const T &,
					std::unordered_map<std::string, std::unique_ptr<aligner>>&, aligner&)> getMismatchesFunc =
			[&alignerLock](const T & read1, const T & read2,
					std::unordered_map<std::string, std::unique_ptr<aligner>>& aligners,
					aligner &alignerObj) {
				alignerLock.lock();
				auto threadId = estd::to_string(std::this_thread::get_id());
				//std::cout << threadId<< std::endl;
				if(aligners.find(threadId) == aligners.end()) {
					aligners.emplace(threadId, std::make_unique<aligner>(alignerObj));
				}
				alignerLock.unlock();
				aligners.at(threadId)->alignCache(getSeqBase(read1),getSeqBase(read2), false);
				aligners.at(threadId)->profilePrimerAlignment(getSeqBase(read1), getSeqBase(read2));
				return aligners.at(threadId)->comp_;
			};
	auto distances = getDistanceNonConst(reads, numThreads, getMismatchesFunc,
			aligners, alignerObj);
	return ReadCompGraph(distances, reads);
}
开发者ID:bailey-lab,项目名称:bibseq,代码行数:25,代码来源:ReadCompGraph.hpp

示例4: if

inline std::pair<bool, AgentPos> help_findAroundDirection(const std::unordered_map<AgentPos, bool>& versionMap, bool iscover, const AgentPos& mypos)
{
    AgentPos around[4] = {{mypos.x+1, mypos.y},{mypos.x-1, mypos.y},{mypos.x, mypos.y+1},{mypos.x, mypos.y-1}};
    std::vector<AgentPos> founds;
    AgentPos notInThree;
    for (auto pos : around) {
        if (iscover) {
            if (versionMap.at(pos) == false) founds.push_back(pos);
            else notInThree = pos;
        } else {
            if (versionMap.at(pos) == true) founds.push_back(pos);
            else notInThree = pos;
        }
    }
    if (founds.size() == 4) {
        return {false, {0,0}};
    } else if (founds.size() > 0 && founds.size() == 3) {
        int x = mypos.x == notInThree.x ? mypos.x : notInThree.x < mypos.x ? mypos.x+1: mypos.x -1;
        int y = mypos.y == notInThree.y ? mypos.y : notInThree.y < mypos.y ? mypos.y +1:mypos.y -1;
        return {true, {x,y}};
    } else if (founds.size() > 0) {
        return {true, founds[static_cast<int>(rand_0_1()*100)%founds.size()]};
    } else {
        return {false, {0,0}};
    }
}
开发者ID:dgkae,项目名称:triplequest,代码行数:26,代码来源:BattleField-cover.cpp

示例5: sample

void Chain::sample(  std::unordered_map<nat,TopologyFile> &paramId2TopFile ,  ParameterFile &pFile ) const
{
  auto blParamsUnfixed=  std::vector<AbstractParameter*>{} ; 
  AbstractParameter *topoParamUnfixed = nullptr; 
  
  for(auto &param : _params  ) 
    {
      if(param->getCategory() == Category::BRANCH_LENGTHS && param->getPrior()->needsIntegration() )
	blParamsUnfixed.push_back(param); 
      else if(param->getCategory() == Category::TOPOLOGY && param->getPrior()->needsIntegration() )
	topoParamUnfixed = param  ; 
    }

  if(blParamsUnfixed.size() > 0)
    {
      for(auto &param : blParamsUnfixed)
	{
	  nat myId = param->getId(); 
	  auto &f = paramId2TopFile.at(myId); 
	  f.sample(_traln, getGeneration(), param); 
	}
    }
  else if(topoParamUnfixed != nullptr)
    {
      auto &f = paramId2TopFile.at(topoParamUnfixed->getId()); 
      f.sample(_traln, getGeneration(), topoParamUnfixed); 
    }

  pFile.sample( _traln, _params, getGeneration(), _prior.getLnPrior()); 
}
开发者ID:pombredanne,项目名称:exa-bayes,代码行数:30,代码来源:Chain.cpp

示例6: CompileFromSource

bool Shader::CompileFromSource(const std::string& pathToFile, const EShaderStage& type, ID3D10Blob *& ref_pBob, std::string& errMsg, const std::vector<ShaderMacro>& macros)
{
	const StrUtil::UnicodeString Path = pathToFile;
	const WCHAR* PathStr = Path.GetUnicodePtr();
	ID3D10Blob* errorMessage = nullptr;

	int i = 0;
	std::vector<D3D10_SHADER_MACRO> d3dMacros(macros.size() + 1);
	std::for_each(RANGE(macros), [&](const ShaderMacro& macro)
	{
		d3dMacros[i++] = D3D10_SHADER_MACRO({ macro.name.c_str(), macro.value.c_str() });
	});
	d3dMacros[i] = { NULL, NULL };

	if (FAILED(D3DCompileFromFile(
		PathStr,
		d3dMacros.data(),
		SHADER_INCLUDE_HANDLER,
		SHADER_ENTRY_POINT_LOOKUP.at(type),
		SHADER_COMPILER_VERSION_LOOKUP.at(type),
		SHADER_COMPILE_FLAGS,
		0,
		&ref_pBob,
		&errorMessage)))
	{

		errMsg = GetCompileError(errorMessage, pathToFile);
		return false;
	}
	return true;
}
开发者ID:vilbeyli,项目名称:DX11Renderer,代码行数:31,代码来源:Shader.cpp

示例7: cellVideoOutGetDeviceInfo

error_code cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideoOutDeviceInfo> info)
{
	cellSysutil.warning("cellVideoOutGetDeviceInfo(videoOut=%d, deviceIndex=%d, info=*0x%x)", videoOut, deviceIndex, info);

	if (deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;

	// Use standard dummy values for now.
	info->portType = CELL_VIDEO_OUT_PORT_HDMI;
	info->colorSpace = CELL_VIDEO_OUT_COLOR_SPACE_RGB;
	info->latency = 100;
	info->availableModeCount = 1;
	info->state = CELL_VIDEO_OUT_DEVICE_STATE_AVAILABLE;
	info->rgbOutputRange = 1;
	info->colorInfo.blueX = 0xFFFF;
	info->colorInfo.blueY = 0xFFFF;
	info->colorInfo.greenX = 0xFFFF;
	info->colorInfo.greenY = 0xFFFF;
	info->colorInfo.redX = 0xFFFF;
	info->colorInfo.redY = 0xFFFF;
	info->colorInfo.whiteX = 0xFFFF;
	info->colorInfo.whiteY = 0xFFFF;
	info->colorInfo.gamma = 100;
	info->availableModes[0].aspect = g_video_out_aspect_id.at(g_cfg.video.aspect_ratio);
	info->availableModes[0].conversion = CELL_VIDEO_OUT_DISPLAY_CONVERSION_NONE;
	info->availableModes[0].refreshRates =  CELL_VIDEO_OUT_REFRESH_RATE_60HZ;
	info->availableModes[0].resolutionId = g_video_out_resolution_id.at(g_cfg.video.resolution);
	info->availableModes[0].scanMode = CELL_VIDEO_OUT_SCAN_MODE_PROGRESSIVE;
	return CELL_OK;
}
开发者ID:cornytrace,项目名称:rpcs3,代码行数:29,代码来源:cellVideoOut.cpp

示例8: computeIntersections

std::vector<std::pair<std::pair<DocId, DocId>, double>>
computeSimilarities(std::unordered_map<DocId, Document> docs) {
  DocSimilarities result = computeIntersections(docs);

  result.forEach([&docs, &result] (DocId id1, DocId id2, double similarity) mutable {
    double docsUnion = docs.at(id1).data.size() + docs.at(id2).data.size() - similarity;
    result.setSimilarity(id1, id2, similarity / docsUnion);
  });

  return result.pairs();
}
开发者ID:DariaP,项目名称:coding,代码行数:11,代码来源:sparseSimilarity.cpp

示例9: init

void GateModule::init(const std::unordered_map<std::string, std::string>& config)
{
	std::string name = config.at("name");
	std::string ip = config.at("ip");
	std::string port = config.at("port");
	std::string thread_num = config.at("net_thread_num");

	set_name(name);

	init_net(std::stoi(thread_num));

	listen(ip, port);
}
开发者ID:dr520,项目名称:moon_net,代码行数:13,代码来源:GateModule.cpp

示例10: return

// 10^nを漢数字に変換する
std::string KanjiOf10ToPower(int n) {
  const std::unordered_map<int, std::string> kanji_scale_map = {
    {0, "一"}, {1, "十"}, {2, "百"}, {3, "千"},
    {4, "万"},
    {8, "億"},
  };

  const int base = n % 4;  // 一, 十, 百, 千の4つ
  const int scale = n / 4 * 4; // ex) n = 5, 5 / 4 = 1, 1 * 4 = 4

  return (base == 0 && n > 0 ? "" : kanji_scale_map.at(base))  // n = 4 とか 8 のときは '一' を省略
    + (scale > 0 ? kanji_scale_map.at(scale) : "");
}
开发者ID:tyamag,项目名称:cpp_seminar,代码行数:14,代码来源:main.cpp

示例11: selectLumaFunction

LUMAFunction selectLumaFunction(unsigned width, unsigned height, unsigned bits, int opt) {
    LUMAFunction luma = luma_functions.at(KEY(width, height, bits, Scalar));

#if defined(MVTOOLS_X86)
    if (opt) {
        try {
            luma = luma_functions.at(KEY(width, height, bits, SSE2));
        } catch (std::out_of_range &) { }
    }
#endif

    return luma;
}
开发者ID:darealshinji,项目名称:vapoursynth-plugins,代码行数:13,代码来源:Luma.cpp

示例12: unsub

 int unsub()
 {
     std::string sig(cmd + UNSUB_LEN);
     if (subs.count(sig) > 0)
     {
         subs.at(sig).erase(socket);
         if (subs.at(sig).size() == 0)
         {
             subs.erase(sig);
             signals.erase(sig);
         }
     }
     return sig.length();
 }
开发者ID:shagal239,项目名称:os,代码行数:14,代码来源:sigd.cpp

示例13: cellVideoOutGetResolutionAvailability

error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, u32 aspect, u32 option)
{
	cellSysutil.warning("cellVideoOutGetResolutionAvailability(videoOut=%d, resolutionId=0x%x, aspect=%d, option=%d)", videoOut, resolutionId, aspect, option);

	switch (videoOut)
	{
	case CELL_VIDEO_OUT_PRIMARY: return not_an_error(
		resolutionId == g_video_out_resolution_id.at(g_cfg.video.resolution)
		&& (aspect == CELL_VIDEO_OUT_ASPECT_AUTO || aspect == g_video_out_aspect_id.at(g_cfg.video.aspect_ratio))
	);
	case CELL_VIDEO_OUT_SECONDARY: return not_an_error(0);
	}

	return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
开发者ID:cornytrace,项目名称:rpcs3,代码行数:15,代码来源:cellVideoOut.cpp

示例14: action

http::doc action(const std::string &verb, const std::unordered_map<std::string, std::string> &args)
{
	if (verb == "refresh")
	{
		volumes.refresh();
		return http::redirect("/");
	}
	else if (verb == "pref")
	{
		std::string old_basedir = prefs::get("basedir");
		for (const std::pair<const std::string, std::string> &kvpair : args)
		{
			try { prefs::set(kvpair.first, kvpair.second); }
			catch (std::out_of_range &e) { continue; }
		}
		prefs::write();
		if (prefs::get("basedir") != old_basedir) volumes.init(prefs::get("basedir"));
		return http::redirect("/");
	}
	else if (verb == "add")
	{
		for (const std::string & reqarg : {"home", "location", "id"}) if (! args.count(reqarg)) return error("Volume Creation Failed", "Required parameter “" + reqarg + "” is missing.");
		std::string srcdir = args.at("location");
		std::string id = args.at("id");
		std::unordered_map<std::string, std::string> info;
		info["home"] = args.at("home");
		for (const std::string &property : {"title", "favicon"}) if (args.count(property)) info[property] = args.at(property);
		std::unordered_set<std::string> keynames{};
		for (const std::pair<const std::string, std::string> &pair : args)
		{
			std::smatch match{};
			if (std::regex_search(pair.first, match, std::regex{"^key_(.*)$"})) keynames.insert(match[1]);
		}
		for (const std::string &key : keynames) if (args.count("key_" + key) && args.count("value_" + key)) info[args.at("key_" + key)] = args.at("value_" + key);
		try { Volume::create(srcdir, prefs::get("basedir"), id, info); }
		catch(std::runtime_error &e) { return error("Volume Creation Failed", e.what()); }
		volumes.refresh();
		return http::redirect("/");
	}
	else if (verb == "quit") std::exit(0);
	/*else if (verb == "debug")
	{
		std::stringstream buf{};
		for (const std::pair<const std::string, std::string> &arg : args) buf << arg.first << " = " << arg.second << "\n";
		return http::doc{"text/plain", buf.str()};
	}*/
	else return error("Bad Request", "Unknown action “" + verb + "”");
}
开发者ID:showermat,项目名称:zsr-utils,代码行数:48,代码来源:zsrsrv.cpp

示例15: findPedType

 static PedType findPedType(const std::string& name) {
     static const std::unordered_map<std::string, PedType> pedTypes{
         // III
         {"PLAYER1", PLAYER1},
         {"PLAYER2", PLAYER2},
         {"PLAYER3", PLAYER3},
         {"PLAYER4", PLAYER4},
         {"CIVMALE", CIVMALE},
         {"CIVFEMALE", CIVFEMALE},
         {"COP", COP},
         {"GANG1", GANG1},
         {"GANG2", GANG2},
         {"GANG3", GANG3},
         {"GANG4", GANG4},
         {"GANG5", GANG5},
         {"GANG6", GANG6},
         {"GANG7", GANG7},
         {"GANG8", GANG8},
         {"GANG9", GANG9},
         {"EMERGENCY", EMERGENCY},
         {"FIREMAN", FIREMAN},
         {"CRIMINAL", CRIMINAL},
         {"PROSTITUTE", PROSTITUTE},
         {"SPECIAL", SPECIAL},
     };
     return pedTypes.at(name);
 }
开发者ID:aldoxtor,项目名称:openrw,代码行数:27,代码来源:ModelData.hpp


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