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


C++ MapEntry类代码示例

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


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

示例1: data

void InstanceMgr::BuildSavedRaidInstancesForPlayer(Player* plr)
{
	WorldPacket data(SMSG_RAID_INSTANCE_INFO, 200);
	Instance * in;
	InstanceMap::iterator itr;
	uint32 i;
	uint32 counter = 0;

	data << counter;
	for(i = 0; i < NUM_MAPS; i++)
	{
		MapEntry* map = dbcMap.LookupEntry(i);
		if(map)
		{
			in = GetSavedInstance(i, plr->GetLowGUID(), plr->iRaidType);
			if(in && map->israid())
			{
				data << in->m_mapId;
				data << in->m_difficulty;
				data << uint64(in->m_instanceId);
				data << uint8(in->m_expiration < UNIXTIME ? 0 : 1);
				data << uint8(0);
				if( in->m_expiration > UNIXTIME )
					data << uint32(in->m_expiration - UNIXTIME);
				else
					data << uint32(0);

				++counter;
			}
		}
	}

	*(uint32*)&data.contents()[0] = counter;
	plr->GetSession()->SendPacket(&data);
}
开发者ID:SkyFire,项目名称:sandshroud,代码行数:35,代码来源:WorldCreator.cpp

示例2: populateMap

void LinkedHashMapTest::testEntrySetIterator() {

    LinkedHashMap<int, std::string> map;
    populateMap(map);

    int count = 0;
    Pointer< Iterator<MapEntry<int, std::string> > > iterator(map.entrySet().iterator());
    while (iterator->hasNext()) {
        MapEntry<int, std::string> entry = iterator->next();
        CPPUNIT_ASSERT_EQUAL(count, entry.getKey());
        CPPUNIT_ASSERT_EQUAL(Integer::toString(count), entry.getValue());
        count++;
    }

    CPPUNIT_ASSERT_MESSAGE("Iterator didn't cover the expected range", count++ == MAP_SIZE);

    iterator.reset(map.entrySet().iterator());
    CPPUNIT_ASSERT_THROW_MESSAGE(
        "Should throw an IllegalStateException",
        iterator->remove(),
        IllegalStateException);

    count = 0;
    while (iterator->hasNext()) {
        iterator->next();
        iterator->remove();
        count++;
    }

    CPPUNIT_ASSERT_MESSAGE("Iterator didn't remove the expected range", count++ == MAP_SIZE);
    CPPUNIT_ASSERT_THROW_MESSAGE(
        "Should throw an IllegalStateException",
        iterator->remove(),
        IllegalStateException);
}
开发者ID:apache,项目名称:activemq-cpp,代码行数:35,代码来源:LinkedHashMapTest.cpp

示例3: is_left_child

 bool is_left_child(const MapEntry &x) {
   if (x.null())
     return false;
   MapEntry rhs(x.parent());
   rhs.SetEntry(rhs.left());
   return x.value() == rhs.value();
 }
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:7,代码来源:LibCxxMap.cpp

示例4: AllocateMap

void ThreadTree::FixOverlappedMap(std::set<MapEntry*, MapComparator>* map_set, const MapEntry* map) {
  for (auto it = map_set->begin(); it != map_set->end();) {
    if ((*it)->start_addr >= map->get_end_addr()) {
      // No more overlapped maps.
      break;
    }
    if ((*it)->get_end_addr() <= map->start_addr) {
      ++it;
    } else {
      MapEntry* old = *it;
      if (old->start_addr < map->start_addr) {
        MapEntry* before = AllocateMap(MapEntry(old->start_addr, map->start_addr - old->start_addr,
                                                old->pgoff, old->time, old->dso));
        map_set->insert(before);
      }
      if (old->get_end_addr() > map->get_end_addr()) {
        MapEntry* after = AllocateMap(
            MapEntry(map->get_end_addr(), old->get_end_addr() - map->get_end_addr(),
                     map->get_end_addr() - old->start_addr + old->pgoff, old->time, old->dso));
        map_set->insert(after);
      }

      it = map_set->erase(it);
    }
  }
}
开发者ID:Khaon,项目名称:android_system_extras,代码行数:26,代码来源:thread_tree.cpp

示例5:

ItemID
TerrainMap::get(BlockPosition x, BlockPosition y, BlockPosition z)
{
	if (x < 0 || x >= _size) return 0;
	if (y < 0 || y >= _size) return 0;
	if (z < 0 || z >= _size) return 0;

	std::size_t index = ray::hash_int(x, y, z) & _mask;

	MapEntry* entry = &_data[index];

	while (!entry->empty())
	{
		if (entry->x == x &&
			entry->y == y &&
			entry->z == z)
		{
			return entry->instanceID;
		}

		index = (index + 1) & _mask;
		entry = &_data[index];
	}

	return 0;
}
开发者ID:Kingwl,项目名称:ray,代码行数:26,代码来源:terrain_map.cpp

示例6: entries

std::string PrimitiveMap::toString() const {

    ostringstream stream;

    stream << "Begin Class PrimitiveMap:" << std::endl;

    Pointer< Iterator<MapEntry<std::string, PrimitiveValueNode> > > entries(this->entrySet().iterator());
    while (entries->hasNext()) {
        MapEntry<std::string, PrimitiveValueNode> entry = entries->next();
        stream << "map[" << entry.getKey() << "] = " << entry.getValue().toString() << std::endl;

    }

    stream << "End Class PrimitiveMap:" << std::endl;

    return stream.str();
}
开发者ID:apache,项目名称:activemq-cpp,代码行数:17,代码来源:PrimitiveMap.cpp

示例7: iterator

void LinkedHashMapTest::testEntrySet() {

    LinkedHashMap<int, std::string> hashMap;

    for (int i = 0; i < 50; i++) {
        hashMap.put(i, Integer::toString(i));
    }

    Set<MapEntry<int, std::string> >& set = hashMap.entrySet();
    Pointer< Iterator<MapEntry<int, std::string> > > iterator(set.iterator());

    CPPUNIT_ASSERT_MESSAGE("Returned set of incorrect size", hashMap.size() == set.size());
    while (iterator->hasNext()) {
        MapEntry<int, std::string> entry = iterator->next();
        CPPUNIT_ASSERT_MESSAGE("Returned incorrect entry set",
                               hashMap.containsKey(entry.getKey()) && hashMap.containsValue(entry.getValue()));
    }

    iterator.reset(set.iterator());
    set.remove(iterator->next());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Remove on set didn't take", 49, set.size());
}
开发者ID:apache,项目名称:activemq-cpp,代码行数:22,代码来源:LinkedHashMapTest.cpp

示例8:

bool
Map::addEntry(MapEntry& mpe)
{
  //cout << mpe;
  std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
                                                  m_table.end(),
                                                  ndn::bind(&mapEntryCompareByRouter,
                                                            _1, mpe.getRouter()));
  if (it == m_table.end()) {
    m_table.push_back(mpe);
    return true;
  }
  return false;
}
开发者ID:vslehman,项目名称:NLSR,代码行数:14,代码来源:map.cpp

示例9: DEBUG_LOG

void WorldSession::_HandleAreaTriggerOpcode(uint32 id)
{		
	DEBUG_LOG( "WorldSession","HandleAreaTriggerOpcode: %u", id);

	// Are we REALLY here?
	CHECK_INWORLD_RETURN;

	// Search quest log, find any exploration quests
	sQuestMgr.OnPlayerExploreArea(GetPlayer(),id);

	AreaTrigger* pAreaTrigger = AreaTriggerStorage.LookupEntry( id );

	sHookInterface.OnAreaTrigger(_player, id);
	CALL_INSTANCE_SCRIPT_EVENT( _player->GetMapMgr(), OnAreaTrigger )( _player, id );

	// if in BG handle is triggers
	if( _player->m_bg )
	{
		_player->m_bg->HookOnAreaTrigger(_player, id);
		return;
	}

	// Hook for Scripted Areatriggers
	_player->GetMapMgr()->HookOnAreaTrigger(_player, id);

	if( _player->GetSession()->CanUseCommand('z') )
	{
		if( pAreaTrigger != NULL )
			sChatHandler.BlueSystemMessage( this, "[%sSystem%s] |rEntered areatrigger: %s%u (%s).", MSG_COLOR_WHITE, MSG_COLOR_LIGHTBLUE, MSG_COLOR_SUBWHITE, id, pAreaTrigger->Name );
		else
			sChatHandler.BlueSystemMessage( this, "[%sSystem%s] |rEntered areatrigger: %s%u", MSG_COLOR_WHITE, MSG_COLOR_LIGHTBLUE, MSG_COLOR_SUBWHITE, id);
	}

	if( pAreaTrigger == NULL )
	{
		OUT_DEBUG("Missing AreaTrigger: %u", id);
		return;
	}

	switch(pAreaTrigger->Type)
	{
	case ATTYPE_INSTANCE:
		{
			if(_player->GetPlayerStatus() != TRANSFER_PENDING) //only ports if player is out of pendings
			{
				MapInfo * pMi = WorldMapInfoStorage.LookupEntry(pAreaTrigger->Mapid);
				MapEntry* map = dbcMap.LookupEntry(pAreaTrigger->Mapid);
				if(!pMi)
					return;

				//do we meet the map requirements?
				uint8 reason = CheckTeleportPrerequsites(pAreaTrigger, this, _player, pAreaTrigger->Mapid);
				if(reason != AREA_TRIGGER_FAILURE_OK)
				{
					const char * pReason = AreaTriggerFailureMessages[reason];
					char msg[200];
					WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 50);
					data << uint32(0);

					switch (reason)
					{
					case AREA_TRIGGER_FAILURE_LEVEL:
						{
							snprintf(msg,200,pReason,pAreaTrigger->required_level);
							data << msg;
						}break;
					case AREA_TRIGGER_FAILURE_NO_ATTUNE_I:
						{
							ItemPrototype * pItem = ItemPrototypeStorage.LookupEntry(pMi->required_item);
							snprintf(msg, 200, pReason, pItem ? pItem->Name1 : "UNKNOWN");
							data << msg;
						}break;
					case AREA_TRIGGER_FAILURE_NO_ATTUNE_Q:
						{
							Quest * pQuest = QuestStorage.LookupEntry(pMi->required_quest);
							snprintf(msg, 200, pReason, pQuest ? pQuest->title : "UNKNOWN");

							data << msg;
						}break;
					case AREA_TRIGGER_FAILURE_NO_KEY:
						{
							string temp_msg[2];
							string tmp_msg;
							for(uint32 i = 0; i < 2; ++i) 
							{
								if (pMi->heroic_key[i] && _player->GetItemInterface()->GetItemCount(pMi->heroic_key[i], false)==0)
								{
									ItemPrototype * pKey = ItemPrototypeStorage.LookupEntry(pMi->heroic_key[i]);
									if(pKey)
										temp_msg[i] += pKey->Name1;
									else
										temp_msg[i] += "UNKNOWN";
								}
							}
							tmp_msg += temp_msg[0];
							if(temp_msg[0].size() && temp_msg[1].size())
								tmp_msg += "\" and \"";
							tmp_msg += temp_msg[1];

							snprintf(msg, 200, pReason, tmp_msg.c_str());
//.........这里部分代码省略.........
开发者ID:arcticdev,项目名称:arcticdev,代码行数:101,代码来源:AreaTrigger.cpp

示例10: mapEntryCompareByMappingNo

static bool
mapEntryCompareByMappingNo(MapEntry& mpe1, int32_t mappingNo)
{
  return mpe1.getMappingNumber() == mappingNo;
}
开发者ID:vslehman,项目名称:NLSR,代码行数:5,代码来源:map.cpp

示例11: mapEntryCompareByRouter

static bool
mapEntryCompareByRouter(MapEntry& mpe1, const ndn::Name& rtrName)
{
  return mpe1.getRouter() == rtrName;
}
开发者ID:vslehman,项目名称:NLSR,代码行数:5,代码来源:map.cpp

示例12: PreTeleport

uint32 InstanceMgr::PreTeleport(uint32 mapid, Player* plr, uint32 instanceid)
{
	// preteleport is where all the magic happens :P instance creation, etc.
	MapInfo * inf = LimitedMapInfoStorage.LookupEntry(mapid);
	MapEntry* map = dbcMap.LookupEntry(mapid);
	InstanceMap * instancemap;
	Instance * in = NULL;

	//is the map vaild?
	if(inf == NULL || mapid >= NUM_MAPS)
		return INSTANCE_ABORT_NOT_FOUND;

	// main continent check.
	if(inf->type == INSTANCE_NULL) // we can check if the destination world server is online or not and then cancel them before they load.
		return (m_singleMaps[mapid] != NULL) ? INSTANCE_OK : INSTANCE_ABORT_NOT_FOUND;

	// shouldn't happen
	if(inf->type == INSTANCE_PVP)
		return INSTANCE_ABORT_NOT_FOUND;

	if(map->israid()) // check that heroic mode is available if the player has requested it.
	{
		if(plr->iRaidType > 1 && inf->type != INSTANCE_MULTIMODE)
			return INSTANCE_ABORT_HEROIC_MODE_NOT_AVAILABLE;
	}
	else if(plr->iInstanceType && inf->type != INSTANCE_MULTIMODE)
		return INSTANCE_ABORT_HEROIC_MODE_NOT_AVAILABLE;

	//do we need addition raid/heroic checks?
	Group * pGroup = plr->GetGroup() ;
	if( !plr->triggerpass_cheat )
	{
		// players without groups cannot enter raid instances (no soloing them:P)
		if( pGroup == NULL && (map->israid() || inf->type == INSTANCE_MULTIMODE))
			return INSTANCE_ABORT_NOT_IN_RAID_GROUP;

		//and has the required level
		if( plr->getLevel() < 80)
		{
			if(!map->israid())
			{
				//otherwise we still need to be lvl 70/80 for heroic.
				if( plr->iInstanceType && plr->getLevel() < uint32(inf->HasFlag(WMI_INSTANCE_XPACK_02) ? 80 : 70))
					return INSTANCE_ABORT_HEROIC_MODE_NOT_AVAILABLE;
			}
			else
				//otherwise we still need to be lvl 70/80 for heroic.
				if( plr->iRaidType > 1 && plr->getLevel() < uint32(inf->HasFlag(WMI_INSTANCE_XPACK_02) ? 80 : 70))
					return INSTANCE_ABORT_HEROIC_MODE_NOT_AVAILABLE;

			//and we might need a key too.
			bool reqkey = (inf->heroic_key[0] || inf->heroic_key[1])? true : false;
			bool haskey = (plr->GetItemInterface()->GetItemCount(inf->heroic_key[0], false) || plr->GetItemInterface()->GetItemCount(inf->heroic_key[1], false))? true : false;
			if(reqkey && !haskey)
				return INSTANCE_ABORT_HEROIC_MODE_NOT_AVAILABLE;
		}
	}

	// if we are here, it means:
	// 1) we're a non-raid instance
	// 2) we're a raid instance, and the person is in a group.
	// so, first we have to check if they have an instance on this map already, if so, allow them to teleport to that.
	// next we check if there is a saved instance belonging to him.
	// otherwise, we can create them a new one.

	m_mapLock.Acquire();

	//find all instances for our map
	instancemap = m_instances[mapid];
	if(instancemap)
	{
		InstanceMap::iterator itr;
		// do we have a specific instance id we should enter (saved or active).
		// don't bother looking for saved instances, if we had one we found it in areatrigger.cpp
		if(instanceid != 0)
		{
			itr = instancemap->find(instanceid);
			if(itr != instancemap->end())
			{
				in = itr->second;
				//we have an instance,but can we enter it?
				uint8 owns = PlayerOwnsInstance( in, plr );
				if( owns >= OWNER_CHECK_OK )
				{
					// If the map is active and has players
					if(in->m_mapMgr && in->m_mapMgr->HasPlayers() && !plr->triggerpass_cheat)
					{
						//check if combat is in progress
						if( in->m_mapMgr->IsCombatInProgress())
						{
							m_mapLock.Release();
							return INSTANCE_ABORT_ENCOUNTER;
						}

						// check if we are full
						if( in->m_mapMgr->GetPlayerCount() >= inf->playerlimit )
						{
							m_mapLock.Release();
							return INSTANCE_ABORT_FULL;
						}
//.........这里部分代码省略.........
开发者ID:SkyFire,项目名称:sandshroud,代码行数:101,代码来源:WorldCreator.cpp


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