• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UNORDERED_MAP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getId

bool CNodeDefManager::getIds(const std::string &name,
		std::set<content_t> &result) const
{
	//TimeTaker t("getIds", NULL, PRECISION_MICRO);
	if (name.substr(0,6) != "group:") {
		content_t id = CONTENT_IGNORE;
		bool exists = getId(name, id);
		if (exists)
			result.insert(id);
		return exists;
	}
	std::string group = name.substr(6);

	UNORDERED_MAP<std::string, GroupItems>::const_iterator
		i = m_group_to_items.find(group);
	if (i == m_group_to_items.end())
		return true;

	const GroupItems &items = i->second;
	for (GroupItems::const_iterator j = items.begin();
		j != items.end(); ++j) {
		if ((*j).second != 0)
			result.insert((*j).first);
	}
	//printf("getIds: %dus\n", t.stop());
	return true;
}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:27,代码来源:nodedef.cpp


示例2: assert

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 (UNORDERED_MAP<std::string, GroupItems>::iterator iter_groups =
			m_group_to_items.begin();
			iter_groups != m_group_to_items.end();) {
		GroupItems &items = iter_groups->second;
		for (GroupItems::iterator iter_groupitems = items.begin();
				iter_groupitems != items.end();) {
			if (iter_groupitems->first == id)
				items.erase(iter_groupitems++);
			else
				iter_groupitems++;
		}

		// Check if group is empty
		if (items.size() == 0)
			m_group_to_items.erase(iter_groups++);
		else
			iter_groups++;
	}
}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:32,代码来源:nodedef.cpp


示例3: SelectRandomNotStomach

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

            UNORDERED_MAP<uint64, 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* pUnit = Unit::GetUnit(*me, i->first);

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

                ++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 , rand() % (temp.size() - 1));

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


示例4: isFreeClientActiveObjectId

bool isFreeClientActiveObjectId(const u16 id,
	UNORDERED_MAP<u16, ClientActiveObject*> &objects)
{
	if(id == 0)
		return false;

	return objects.find(id) == objects.end();
}
开发者ID:DomtronVox,项目名称:minetest,代码行数:8,代码来源:clientenvironment.cpp


示例5: Reset

    void Reset()
    {
        m_uiMorphTimer = 0;

        for (UNORDERED_MAP<uint8, uint32>::iterator itr = m_mSpellTimers.begin(); itr != m_mSpellTimers.end(); ++itr)
            itr->second = m_aSpitelashAbility[itr->first].m_uiInitialTimer;
    }
开发者ID:Shutok,项目名称:StrawberryCore-501Beta,代码行数:7,代码来源:azshara.cpp


示例6: UpdateAI

    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiMorphTimer)
        {
            if (m_uiMorphTimer <= uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_POLYMORPH_BACKFIRE, CAST_TRIGGERED) == CAST_OK)
                {
                    m_uiMorphTimer = 0;
                    m_creature->ForcedDespawn();
                }
            }
            else
                m_uiMorphTimer -= uiDiff;
        }

        for (UNORDERED_MAP<uint8, uint32>::iterator itr = m_mSpellTimers.begin(); itr != m_mSpellTimers.end(); ++itr)
        {
            if (itr->second < uiDiff)
            {
                if (CanUseSpecialAbility(itr->first))
                {
                    itr->second = m_aSpitelashAbility[itr->first].m_uiCooldown;
                    break;
                }
            }
            else
                itr->second -= uiDiff;
        }

        DoMeleeAttackIfReady();
    }
开发者ID:Shutok,项目名称:StrawberryCore-501Beta,代码行数:35,代码来源:azshara.cpp


示例7: generate_nodelist_and_update_ids

void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount,
	std::vector<std::string> *usednodes, INodeDefManager *ndef)
{
	UNORDERED_MAP<content_t, content_t> nodeidmap;
	content_t numids = 0;

	for (size_t i = 0; i != nodecount; i++) {
		content_t id;
		content_t c = nodes[i].getContent();

		UNORDERED_MAP<content_t, content_t>::const_iterator it = nodeidmap.find(c);
		if (it == nodeidmap.end()) {
			id = numids;
			numids++;

			usednodes->push_back(ndef->get(c).name);
			nodeidmap.insert(std::make_pair(c, id));
		} else {
			id = it->second;
		}
		nodes[i].setContent(id);
	}
}
开发者ID:CasimirKaPazi,项目名称:minetest,代码行数:23,代码来源:mg_schematic.cpp


示例8: HasAuraName

bool bot_ai::HasAuraName (Unit *unit, std::string spell, uint64 casterGuid)
{
    if (spell.length()==0) return false;

    int loc = master->GetSession()->GetSessionDbcLocale();;
    if(unit == NULL) return false;
    Unit *target = unit;
    if(target->isDead()) return false;

    Unit::AuraMap &vAuras = (Unit::AuraMap&)target->GetOwnedAuras();

    //save the map of auras b/c it can crash if an aura goes away while looping
    UNORDERED_MAP<uint64, Aura*> auraMap;
    for(Unit::AuraMap::const_iterator iter = vAuras.begin(); iter!= vAuras.end(); ++iter)
    {
         Aura *aura = iter->second;
        (auraMap)[iter->first] = aura;
    }

    // now search our new map
    for(UNORDERED_MAP<uint64, Aura*>::iterator itr = auraMap.begin(); itr!= auraMap.end(); ++itr)
    {
        const SpellEntry *spellInfo = itr->second->GetSpellProto();
        const std::string name = spellInfo->SpellName[loc];
        if(!spell.compare(name))
        {
            if(casterGuid == 0){ //don't care who casted it
                return true;
            } else if(casterGuid == itr->second->GetCasterGUID()){ //only if correct caster casted it
                return true;
            }
        }
    }
    
    return false;
}
开发者ID:Rhyuk,项目名称:Dev,代码行数:36,代码来源:bot_ai.cpp


示例9: HasAuraIcon

bool bot_ai::HasAuraIcon (Unit *unit, uint32 SpellIconID, uint64 casterGuid)
{
    int loc = master->GetSession()->GetSessionDbcLocale();;
    if(unit == NULL) return false;
    Unit *target = unit;
    if(target->isDead()) return false;

    Unit::AuraMap &vAuras = (Unit::AuraMap&)target->GetOwnedAuras();
   
    //save the map of auras b/c it can crash if an aura goes away while looping
    UNORDERED_MAP<uint64, Aura*> auraMap;
    for(Unit::AuraMap::const_iterator iter = vAuras.begin(); iter!= vAuras.end(); ++iter)
    {
         Aura *aura = iter->second;
        (auraMap)[iter->first] = aura;
    }

    // now search our new map
    for(UNORDERED_MAP<uint64, Aura*>::iterator itr = auraMap.begin(); itr!= auraMap.end(); ++itr)
    {
        const SpellEntry *spellInfo = itr->second->GetSpellProto();
        uint32 spelliconId = spellInfo->SpellIconID;
//error_log ("bot_ai.HasAuraICON: %s has icon %u",spellInfo->SpellName[master->GetSession()->GetSessionDbcLocale()],  spellInfo->SpellIconID);
 
        if(spelliconId==SpellIconID)
        {
//error_log ("bot_ai.HasAuraICON: %s has icon %u",spellInfo->SpellName[master->GetSession()->GetSessionDbcLocale()],  spellInfo->SpellIconID);
            if(casterGuid == 0){ //don't care who casted it
                return true;
            } else if(casterGuid == itr->second->GetCasterGUID()){ //only if correct caster casted it
                return true;
            }
        }
    }
    return false;
}
开发者ID:Rhyuk,项目名称:Dev,代码行数:36,代码来源:bot_ai.cpp


示例10: UpdateAI

    void UpdateAI(const uint32 uiDiff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        for (UNORDERED_MAP<uint8, uint32>::iterator itr = m_mSpellTimers.begin(); itr != m_mSpellTimers.end(); ++itr)
        {
            if (itr->second < uiDiff)
            {
                if (CanUseSpecialAbility(itr->first))
                {
                    itr->second = m_aSilverHandAbility[itr->first].m_uiCooldown;
                    break;
                }
            }
            else
                itr->second -= uiDiff;
        }

        DoMeleeAttackIfReady();
    }
开发者ID:Bootz,项目名称:StrawberryCore,代码行数:22,代码来源:boss_order_of_silver_hand.cpp


示例11: UpdateAI


//.........这里部分代码省略.........
                        }

                        //Spawn 2 flesh tentacles
                        FleshTentaclesKilled = 0;

                        //Spawn flesh tentacle
                        for (uint8 i = 0; i < 2; i++)
                        {
                            Creature* spawned = me->SummonCreature(MOB_FLESH_TENTACLE, FleshTentaclePos[i], TEMPSUMMON_CORPSE_DESPAWN);
                            if (!spawned)
                                ++FleshTentaclesKilled;
                        }

                        PhaseTimer = 0;
                    } else PhaseTimer -= diff;

                    break;

                //Body Phase
                case PHASE_CTHUN_STOMACH:
                    //Remove Target field
                    me->SetTarget(0);

                    //Weaken
                    if (FleshTentaclesKilled > 1)
                    {
                        pInst->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_WEAK);

                        DoScriptText(EMOTE_WEAKENED, me);
                        PhaseTimer = 45000;

                        DoCast(me, SPELL_PURPLE_COLORATION, true);

                        UNORDERED_MAP<uint64, bool>::iterator i = Stomach_Map.begin();

                        //Kick all players out of stomach
                        while (i != Stomach_Map.end())
                        {
                            //Check for valid player
                            Unit* pUnit = Unit::GetUnit(*me, i->first);

                            //Only move units in stomach
                            if (pUnit && i->second == true)
                            {
                                //Teleport each player out
                                DoTeleportPlayer(pUnit, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()+10, float(rand()%6));

                                //Cast knockback on them
                                DoCast(pUnit, SPELL_EXIT_STOMACH_KNOCKBACK, true);

                                //Remove the acid debuff
                                pUnit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID);

                                i->second = false;
                            }
                            ++i;
                        }

                        return;
                    }

                    //Stomach acid
                    if (StomachAcidTimer <= diff)
                    {
                        //Apply aura to all players in stomach
                        UNORDERED_MAP<uint64, bool>::iterator i = Stomach_Map.begin();
开发者ID:,项目名称:,代码行数:67,代码来源:


示例12: UpdateAI


//.........这里部分代码省略.........
                        FleshTentaclesKilled++;
                    else
                        ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(me->GetGUID());

                    //Spawn flesh tentacle
                    Spawned = (Creature*)me->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0);

                    if (!Spawned)
                        FleshTentaclesKilled++;
                    else
                        ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(me->GetGUID());

                    PhaseTimer = 0;
                } else PhaseTimer -= diff;

            }break;

            //Body Phase
            case 3:
            {
                //Remove Target field
                me->SetUInt64Value(UNIT_FIELD_TARGET, 0);

                //Weaken
                if (FleshTentaclesKilled > 1)
                {
                    pInst->SetData(DATA_CTHUN_PHASE, 4);

                    DoScriptText(EMOTE_WEAKENED, me);
                    PhaseTimer = 45000;

                    DoCast(me, SPELL_RED_COLORATION, true);

                    UNORDERED_MAP<uint64, bool>::iterator i = Stomach_Map.begin();

                    //Kick all players out of stomach
                    while (i != Stomach_Map.end())
                    {
                        //Check for valid player
                        Unit* pUnit = Unit::GetUnit(*me, i->first);

                        //Only move units in stomach
                        if (pUnit && i->second == true)
                        {
                            //Teleport each player out
                            DoTeleportPlayer(pUnit, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()+10, float(rand()%6));

                            //Cast knockback on them
                            DoCast(pUnit, SPELL_EXIT_STOMACH_KNOCKBACK, true);

                            //Remove the acid debuff
                            pUnit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID);

                            i->second = false;
                        }
                        ++i;
                    }

                    return;
                }

                //Stomach acid
                if (StomachAcidTimer <= diff)
                {
                    //Apply aura to all players in stomach
                    UNORDERED_MAP<uint64, bool>::iterator i = Stomach_Map.begin();
开发者ID:Dudelzack,项目名称:blizzlikecore,代码行数:67,代码来源:boss_cthun.cpp


示例13: Reset

 void Reset()
 {
     for (UNORDERED_MAP<uint8, uint32>::iterator itr = m_mSpellTimers.begin(); itr != m_mSpellTimers.end(); ++itr)
         itr->second = m_aSilverHandAbility[itr->first].m_uiInitialTimer;
 }
开发者ID:Bootz,项目名称:StrawberryCore,代码行数:5,代码来源:boss_order_of_silver_hand.cpp


示例14: UpdatePath

void WaypointStore::UpdatePath(uint32 id)
{

    if(waypoint_map.find(id)!= waypoint_map.end())
        waypoint_map[id]->clear();

    QueryResult *result;

    result = WorldDatabase.PQuery("SELECT `id`,`point`,`position_x`,`position_y`,`position_z`,`move_flag`,`delay`,`action`,`action_chance` FROM `waypoint_data` WHERE id = %u ORDER BY `point`", id);

    if(!result)
        return;

    WaypointPath* path_data;

    path_data = new WaypointPath;

    Field *fields;

    do
    {
        fields = result->Fetch();
        uint32 id = fields[0].GetUInt32();

        WaypointData *wp = new WaypointData;

        float x,y,z;
        x = fields[2].GetFloat();
        y = fields[3].GetFloat();
        z = fields[4].GetFloat();

        Trinity::NormalizeMapCoord(x);
        Trinity::NormalizeMapCoord(y);

        wp->id = fields[1].GetUInt32();
        wp->x = x;
        wp->y = y;
        wp->z = z;
        wp->run = fields[5].GetBool();
        wp->delay = fields[6].GetUInt32();
        wp->event_id = fields[7].GetUInt32();
        wp->event_chance = fields[8].GetUInt8();

        path_data->push_back(wp);

    }while (result->NextRow());

    waypoint_map[id] = path_data;

    delete result;
}
开发者ID:de-dima,项目名称:243,代码行数:51,代码来源:WaypointManager.cpp


示例15: updateAliases

void CNodeDefManager::updateAliases(IItemDefManager *idef)
{
	std::set<std::string> all = idef->getAll();
	m_name_id_mapping_with_aliases.clear();
	for (std::set<std::string>::iterator
			i = all.begin(); i != all.end(); ++i) {
		std::string name = *i;
		std::string convert_to = idef->getAlias(name);
		content_t id;
		if (m_name_id_mapping.getId(convert_to, id)) {
			m_name_id_mapping_with_aliases.insert(
				std::make_pair(name, id));
		}
	}
}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:15,代码来源:nodedef.cpp


示例16: Reset

        void Reset()
        {
            //One random wisper every 90 - 300 seconds
            WisperTimer = 90000;

            //Phase information
            PhaseTimer = 10000;                                 //Emerge in 10 seconds

            //No hold player for transition
            HoldPlayer = 0;

            //Body Phase
            EyeTentacleTimer = 30000;
            FleshTentaclesKilled = 0;
            GiantClawTentacleTimer = 15000;                     //15 seconds into body phase (1 min repeat)
            GiantEyeTentacleTimer = 45000;                      //15 seconds into body phase (1 min repeat)
            StomachAcidTimer = 4000;                            //Every 4 seconds
            StomachEnterTimer = 10000;                          //Every 10 seconds
            StomachEnterVisTimer = 0;                           //Always 3.5 seconds after Stomach Enter Timer
            StomachEnterTarget = 0;                             //Target to be teleported to stomach

            //Clear players in stomach and outside
            Stomach_Map.clear();

            //Reset flags
            me->RemoveAurasDueToSpell(SPELL_TRANSFORM);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
            me->SetVisible(false);

            if (pInst)
                pInst->SetData(DATA_CTHUN_PHASE, PHASE_NOT_STARTED);
        }
开发者ID:,项目名称:,代码行数:32,代码来源:


示例17: addNameIdMapping

void CNodeDefManager::addNameIdMapping(content_t i, std::string name)
{
	m_name_id_mapping.set(i, name);
	m_name_id_mapping_with_aliases.insert(std::make_pair(name, i));
}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:5,代码来源:nodedef.cpp


示例18: clear

void CNodeDefManager::clear()
{
	m_content_features.clear();
	m_name_id_mapping.clear();
	m_name_id_mapping_with_aliases.clear();
	m_group_to_items.clear();
	m_next_id = 0;

	resetNodeResolveState();

	u32 initial_length = 0;
	initial_length = MYMAX(initial_length, CONTENT_UNKNOWN + 1);
	initial_length = MYMAX(initial_length, CONTENT_AIR + 1);
	initial_length = MYMAX(initial_length, CONTENT_IGNORE + 1);
	m_content_features.resize(initial_length);

	// Set CONTENT_UNKNOWN
	{
		ContentFeatures f;
		f.name = "unknown";
		// Insert directly into containers
		content_t c = CONTENT_UNKNOWN;
		m_content_features[c] = f;
		addNameIdMapping(c, f.name);
	}

	// Set CONTENT_AIR
	{
		ContentFeatures f;
		f.name                = "air";
		f.drawtype            = NDT_AIRLIKE;
		f.param_type          = CPT_LIGHT;
		f.light_propagates    = true;
		f.sunlight_propagates = true;
		f.walkable            = false;
		f.pointable           = false;
		f.diggable            = false;
		f.buildable_to        = true;
		f.floodable           = true;
		f.is_ground_content   = true;
		// Insert directly into containers
		content_t c = CONTENT_AIR;
		m_content_features[c] = f;
		addNameIdMapping(c, f.name);
	}

	// Set CONTENT_IGNORE
	{
		ContentFeatures f;
		f.name                = "ignore";
		f.drawtype            = NDT_AIRLIKE;
		f.param_type          = CPT_NONE;
		f.light_propagates    = false;
		f.sunlight_propagates = false;
		f.walkable            = false;
		f.pointable           = false;
		f.diggable            = false;
		f.buildable_to        = true; // A way to remove accidental CONTENT_IGNOREs
		f.is_ground_content   = true;
		// Insert directly into containers
		content_t c = CONTENT_IGNORE;
		m_content_features[c] = f;
		addNameIdMapping(c, f.name);
	}
}
开发者ID:Bremaweb,项目名称:voxeladventures-client,代码行数:65,代码来源:nodedef.cpp


示例19: Free

void WaypointStore::Free()
{
    waypoint_map.clear();
}
开发者ID:artas,项目名称:quademu,代码行数:4,代码来源:WaypointManager.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UNavigationSystem类代码示例发布时间:2022-05-31
下一篇:
C++ UNICHARSET类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap