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


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

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


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

示例1: CheckInstallation

void TestMain::CheckInstallation(std::unordered_map<std::wstring, std::wstring>& expectedContent)
{
	boost::filesystem::directory_iterator itEnd;
	for (boost::filesystem::directory_iterator itFile(datadirPath_ / L"install-test1"); itFile != itEnd; ++itFile) {
		lhWinAPI::TextFile tf(itFile->path().wstring(), GENERIC_READ, 0, OPEN_EXISTING);
		std::wstring txt;
		tf.ReadText(txt, lhWinAPI::TextFile::UTF8);
		std::wstringstream txtStream(txt);
		std::wstring fstLine;
		std::getline(txtStream, fstLine);

		bool foundFile = false;
		for (auto itMap = expectedContent.begin(); itMap != expectedContent.end(); ++itMap) {
			if (boost::iequals(itFile->path().filename().wstring(), itMap->first)) {
				foundFile = true;
				if (boost::iequals(fstLine, itMap->second)) {
					expectedContent.erase(itMap);
					break;
				}
				else {
					throw lhstd::exception(L"wrong version of " + itMap->first + L"\n" +
										   L"Content was: " + fstLine + L"\nExpected: " + itMap->second);
				}
			}
		}

		if (!foundFile) {
			throw lhstd::exception(L"unknown file " + itFile->path().filename().wstring());
		}
	}
	if (!expectedContent.empty()) {
		throw lhstd::exception(L"map not empty - " + expectedContent.begin()->first);
	}
}
开发者ID:Loksim3D,项目名称:loksim3d-source,代码行数:34,代码来源:TestMain.cpp

示例2: logAllData

void logAllData(std::unordered_map<int,Kantai*> _kantaiMap,
                std::unordered_map<int,Equip*> _equipMap,
                std::unordered_map<int,Fleet*> _fleetMap,
                std::unordered_map<int,std::pair<int, int>> _fleetKantaiMap,
                std::unordered_map<int,std::pair<int, int>> _kantaiEquipMap)
{
    log("-------------------------kantai in the map:-------------------------------");
    for (auto it=_kantaiMap.begin(); it!=_kantaiMap.end(); ++it)
    {
        log("kantaiKey: %d   kantaiNumber: %d",it->first,it->second->getKantaiNumber());
    }
    log("-------------------------equip in the map:-------------------------------");
    for (auto it=_equipMap.begin(); it!=_equipMap.end(); ++it)
    {
        log("equipKey: %d   equipNumber: %d",it->first,it->second->getEquipNumber());
    }
    log("-------------------------fleet in the map:-------------------------------");
    for (auto it=_fleetMap.begin(); it!=_fleetMap.end(); ++it)
    {
        log("fleetKey: %d   fleetKey: %d",it->first,it->second->getFleetKey());
    }
    log("-------------------------fleet and kantai relation in the map:-------------------------------");
    for (auto it=_fleetKantaiMap.begin(); it!=_fleetKantaiMap.end(); ++it)
    {
        log("kantaiKey: %d  fleetKey: %d  position: %d",it->first,it->second.first,it->second.second);
    }
    log("-------------------------kantai and equip relation in the map:-------------------------------");
    for (auto it=_kantaiEquipMap.begin(); it!=_kantaiEquipMap.end(); ++it)
    {
        log("equipKey: %d  kantaiKey: %d  position: %d",it->first,it->second.first,it->second.second);
    }
}
开发者ID:zhyl19920810,项目名称:JLU_collection,代码行数:32,代码来源:databaseInit.cpp

示例3: outputCpp

void ParserOutput::outputCpp()
{
  ofstream file(outputfile + ".cpp");
  file << "#include \"" << outputfile << ".h\"" << endl;
  std::string fullFilename(resourceDirectory);
  fullFilename = fullFilename + "astres/SourcePreamble.txt";
  outputFile(&file,fullFilename.c_str());
  rules->outputTypeDefinitions(&file);
  outputListCode(&file);
  {
    auto iter = terminalTokens.begin();
    while (iter != terminalTokens.end())
      {
	file << iter->first << "_Type::" << iter->first << "_Type(char* _matchedText, char* _preceedingWhitespace)" << endl;
	file << ":TerminalTokenBaseClass(_matchedText,_preceedingWhitespace)" << endl;
	file << '{' << endl;
	file << '}' << endl;
	iter++;
      }
  }
  {
    auto iter = stringTokens.begin();
    while (iter != stringTokens.end())
      {
	file << iter->first << "_String_Type::" << iter->first << "_String_Type(char* _matchedText, char* _preceedingWhitespace)" << endl;
	file << ":TerminalTokenBaseClass(_matchedText,_preceedingWhitespace)" << endl;
	file << '{' << endl;
	file << '}' << endl;
	iter++;
      }
  }
}
开发者ID:deek0146,项目名称:ast,代码行数:32,代码来源:CppOutput.cpp

示例4: sendRequestToFriends

void EziSocialObject::sendRequestToFriends(EziSocialWrapperNS::FB_REQUEST::TYPE requestType,
                                           const char* message,
                                           const std::vector<std::string> &selectedFriendIDs,
                                           const std::unordered_map<std::string,std::string> &dataDictionary, const char* customTitle)
{
    
    std::string dataString      = "";
    std::string friendsString   = "";
    
    for(auto it = dataDictionary.begin();it!=dataDictionary.end();++it)
    {
        if (it != dataDictionary.begin())
        {
            dataString.append(",");
        }
        dataString.append(it->first);
        dataString.append(",");
        dataString.append(it->second);
    }
    
    for(auto it = selectedFriendIDs.begin();it!=selectedFriendIDs.end();++it)
    {
        if (it != selectedFriendIDs.begin())
        {
            friendsString.append(",");
        }
        friendsString.append(*it);
    }
    
    EziSocialWrapperNS::sendRequest(internalRequestSendCallback,
                                    requestType,
                                    message,
                                    dataString.c_str(),
                                    friendsString.c_str(), customTitle);
}
开发者ID:piaopolar,项目名称:EziSocial-Plugin,代码行数:35,代码来源:EziSocialObject.cpp

示例5: decltype

std::vector<Motif> StrategyXor::refineByPostive(
	std::unordered_map<Motif, std::pair<int, double>>& data, const size_t gsize, const size_t topk)
{
	vector<pair<int, decltype(data.begin())>> idx;
	int minOcc = static_cast<int>(ceil(pRefine*gsize));
	auto it = data.begin();
	for(size_t i = 0; i < data.size(); ++i, ++it) {
		if(it->second.first >= minOcc) {
			it->second.second /= it->second.first;
			idx.emplace_back(i, it);
		}
	}
	sort(idx.begin(), idx.end(),
		[](const pair<int, decltype(data.begin())>& a, const pair<int, decltype(data.begin())>& b) {
		return a.first > b.first || a.first == b.first && a.second->second > b.second->second;
		//return a.first > b.first;
	});
	cout << "  valid motif: " << idx.size() << endl;

	vector<Motif> res;
	size_t end = min(topk, idx.size());
	for(size_t i = 0; i < end; ++i)
		res.push_back(move(idx[i].second->first));
	return res;
}
开发者ID:yxtj,项目名称:GSDM,代码行数:25,代码来源:StrategyXor.cpp

示例6: impl

    bool impl(std::unordered_map<int, int>& oddMap,
              std::unordered_map<int, int>& evenMap,
              bool isAlice)
    {
        if(!evenMap.empty())
        {
            oddMap[evenMap.begin()->first] = evenMap.begin()->second - 1;
            evenMap.erase(evenMap.begin());
            return impl(oddMap, evenMap, !isAlice);
        }

        if(oddMap.begin()->second > 1)
        {
            evenMap[oddMap.begin()->first] = oddMap.begin()->second - 1;
            oddMap.erase(oddMap.begin());
        }
        else
        {
            oddMap.erase(oddMap.begin());
        }

        if(oddMap.empty()) return isAlice ? false : true;

        return impl(oddMap, evenMap, !isAlice);
    }
开发者ID:knightzf,项目名称:review,代码行数:25,代码来源:main.cpp

示例7: removeNode

void CNodeDefManager::removeNode(const std::string &name)
{
	// Pre-condition
	assert(name != "");

	// Erase name from name ID mapping
	content_t id = CONTENT_IGNORE;
	if (m_name_id_mapping.getId(name, id)) {
		m_name_id_mapping.eraseName(name);
		m_name_id_mapping_with_aliases.erase(name);
	}

	// Erase node content from all groups it belongs to
	for (std::unordered_map<std::string, std::vector<content_t>>::iterator iter_groups =
			m_group_to_items.begin(); iter_groups != m_group_to_items.end();) {
		std::vector<content_t> &items = iter_groups->second;
		items.erase(std::remove(items.begin(), items.end(), id), items.end());

		// Check if group is empty
		if (items.empty())
			m_group_to_items.erase(iter_groups++);
		else
			++iter_groups;
	}
}
开发者ID:EXio4,项目名称:minetest,代码行数:25,代码来源:nodedef.cpp

示例8: init

void init() {
    CLOG(L"Initializing...");

    delete vOSD;
    delete eOSD;

    Settings *settings = Settings::Instance();
    settings->Load();

    SkinManager::Instance()->LoadSkin(settings->SkinXML());

    /* TODO: Detect monitor changes, update this map, and reload/reorg OSDs */
    DisplayManager::UpdateMonitorMap();

    /* OSDs */
    eOSD = new EjectOSD();
    vOSD = new VolumeOSD();

    /* Hotkey setup */
    if (hkManager != NULL) {
        hkManager->Shutdown();
    }
    hkManager = HotkeyManager::Instance(mainWnd);

    hotkeys = Settings::Instance()->Hotkeys();
    for (auto it = hotkeys.begin(); it != hotkeys.end(); ++it) {
        int combination = it->first;
        hkManager->Register(combination);
    }

    WTSRegisterSessionNotification(mainWnd, NOTIFY_FOR_THIS_SESSION);
}
开发者ID:AngryLifeender,项目名称:3RVX,代码行数:32,代码来源:3RVX.cpp

示例9:

 ~Space()
 {
     for (auto it = clusters.begin(); it != clusters.end(); ++it)
     {
         delete it->second;
     }
 }
开发者ID:juronen,项目名称:Dubuskan,代码行数:7,代码来源:space.hpp

示例10: List

// public, static
void Cvar::List( void ) {
	console.Print( PrintLevel::Normal, "Listing cvars...\n" );

	std::map<std::string, Cvar *> sorted( cvars.begin(), cvars.end() );
	std::vector<std::string> keyValues;
	keyValues.reserve( sorted.size() );

	Indent indent( 1 );
	size_t maxLen = 1u;
	for ( const auto &cvar : sorted ) {
		keyValues.push_back( String::Format( "%s = \"%s\"", cvar.first.c_str(), cvar.second->fullString.c_str() ) );
		const size_t len = strlen( keyValues.back().c_str() );
		if ( len > maxLen ) {
			maxLen = len;
		}
	}
	uint32_t i = 0;
	for ( const auto &cvar : sorted ) {
		console.Print( PrintLevel::Normal, "%-*s: %s\n",
			maxLen + 1,
			keyValues[i++].c_str(),
			cvar.second->description.c_str()
		);
	}
}
开发者ID:Razish,项目名称:xsngine,代码行数:26,代码来源:Cvar.cpp

示例11: SelectRandomNotStomach

        Unit* SelectRandomNotStomach()
        {
            if (Stomach_Map.empty())
                return NULL;

            std::unordered_map<ObjectGuid, bool>::const_iterator i = Stomach_Map.begin();

            std::list<Unit*> temp;
            std::list<Unit*>::const_iterator j;

            //Get all players in map
            while (i != Stomach_Map.end())
            {
                //Check for valid player
                Unit* unit = ObjectAccessor::GetUnit(*me, i->first);

                //Only units out of stomach
                if (unit && i->second == false)
                    temp.push_back(unit);

                ++i;
            }

            if (temp.empty())
                return NULL;

            j = temp.begin();

            //Get random but only if we have more than one unit on threat list
            if (temp.size() > 1)
                advance(j, rand32() % (temp.size() - 1));

            return (*j);
        }
开发者ID:Lyill,项目名称:TrinityCore,代码行数:34,代码来源:boss_cthun.cpp

示例12: GetEntryDescriptions

std::string GlobalConfig::GetEntryDescriptions()
{
	std::string out;
	unsigned int descIdx = 0;
	for (auto desc = m_entries.begin(); desc != m_entries.end(); ++desc, ++descIdx)
	{
		out += "##### \"" + desc->first + "\"" + " (" + std::to_string(desc->second.m_value.size()) + " params)\n" + desc->second.m_description;
		if (!desc->second.m_listeners.empty())
		{
			out += "\n[Listeners: ";
			unsigned int listenerIdx = 0;
			for (auto listener = desc->second.m_listeners.begin(); listener != desc->second.m_listeners.end(); ++listener, ++listenerIdx)
			{
				out += "\"" + listener->first + "\"";
				if (listenerIdx < desc->second.m_listeners.size() - 1)
					out += ", ";
			}
			out += "]";
		}
		if (descIdx < m_entries.size() - 1)
			out += "\n\n";
		
	}
	return out;
}
开发者ID:Jojendersie,项目名称:gpugi,代码行数:25,代码来源:globalconfig.cpp

示例13: update

	bool PhysicsEngine::update(float deltaTime){
		_world->stepSimulation(deltaTime, 60);

		//iterate across the contacts map
		for(auto contactsIter = contacts.begin(); contactsIter!=contacts.end(); ++contactsIter){
			//get the entity key from  teh current entry in the map
			Entity* collider0 = contactsIter->first;
			//get the set of colliders from the current entry in the map
			std::set<Entity*>& set = contactsIter->second;
			//iterate thru all the entities in the set
			for(auto entityIter = set.begin(); entityIter!=set.end(); ++entityIter){
				// get the other colider from the iterator
				Entity* collider1 = *entityIter;
				//create 2 messages - one for collider and one for the entity being hit
				Message msg1(collider0, "COLLISION", collider1);
				Message msg2(collider1, "COLLISION", collider0);
				//dispatch teh messages
				MessageHandler::sendMessage(msg1);
				MessageHandler::sendMessage(msg2);
			}
		}
		//empty the contacts map ready for next time
		contacts.clear();

		//for now
		return true;
	}
开发者ID:razvanilin,项目名称:games-engineering-project,代码行数:27,代码来源:PhysicsEngine.cpp

示例14: constructResult

		/**
		 * @brief Construct result, by packing process.
		 */
		void constructResult()
		{
			if (result.empty() == false)
				return;

			// 제품과 포장지 그룹, Product와 WrapperGroup의 1:1 매칭
			for (size_t i = 0; i < size(); i++)
			{
				const std::shared_ptr<Wrapper> &wrapper = at(i);
				if (result.count(wrapper->key()) == 0)
				{
					WrapperGroup *wrapperGroup = new WrapperGroup(wrapper);
					result.insert({ wrapper->key(), std::shared_ptr<WrapperGroup>(wrapperGroup) });
				}

				std::shared_ptr<WrapperGroup> wrapperGroup = result.at(wrapper->key());
				std::shared_ptr<Instance> instance = instanceArray->at(i);

				if (wrapperGroup->allocate(instance) == false)
				{
					// 일개 제품 크기가 포장지보다 커서 포장할 수 없는 경우, 
					// 현재의 염기서열은 유효하지 못하여 폐기됨
					valid = false;
					return;
				}
			}

			// 유효한 염기서열일 때,
			for (auto it = result.begin(); it != result.end(); it++)
			{
				it->second->optimize(); // 세부적(그룹별)으로 bin-packing을 실시함
				price += it->second->getPrice(); // 더불어 가격도 합산해둔다
			}
			valid = true;
		};
开发者ID:betterwaysystems,项目名称:packer,代码行数:38,代码来源:GAWrapperArray.hpp

示例15: OnTick

    void __stdcall OnTick()
    {
        if (ignoreUntilNewGame) return;

        bytesCopied = 0;
        for (int i = 0; i < 16; i++) {
            s_player* player = game::getPlayer(i);
            if (player) {
                auto& history = playerHistory[player->memory_id];

                objects::s_halo_biped* obj = (objects::s_halo_biped*)
                    objects::GetObjectAddress(player->mem->object_id);
                if (obj) {
                    history.add(obj);
                } else {
                    // object is no longer valid (i.e. player died)
                    history.clear();
                }
            }
        }

        for (auto itr = vehicleHistory.begin(); itr != vehicleHistory.end(); ++itr) {
            objects::s_halo_vehicle* obj = (objects::s_halo_vehicle*)
                objects::GetObjectAddress(make_ident(itr->first));
            if (obj) {
                itr->second.add(obj);
            } else {
                itr->second.clear();
            }
        }
    }
开发者ID:ChadSki,项目名称:Phasor,代码行数:31,代码来源:Lead.cpp


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