//---------------------------------------------------------------------- // delete info //---------------------------------------------------------------------- void UserInfoManager::deleteUserInfo (ZoneGroupID_t ServerGroupID, WorldID_t WorldID ) throw(NoSuchElementException ) { __BEGIN_TRY HashMapUserInfo::iterator itr = m_UserInfos[WorldID].find(ServerGroupID); if (itr != m_UserInfos[WorldID].end() ) { // UserInfo 를 삭제한다. delete itr->second; // pair를 삭제한다. m_UserInfos[WorldID].erase(itr); } else { // not found StringStream msg; msg << "ServerGroupID: " << ServerGroupID; throw NoSuchElementException(msg.toString()); } __END_CATCH }
//---------------------------------------------------------------------- // get info //---------------------------------------------------------------------- UserInfo * UserInfoManager::getUserInfo (ZoneGroupID_t ServerGroupID, WorldID_t WorldID ) const throw(NoSuchElementException ) { __BEGIN_TRY UserInfo * pUserInfo = NULL; HashMapUserInfo::const_iterator itr = m_UserInfos[WorldID].find(ServerGroupID); if (itr != m_UserInfos[WorldID].end() ) { pUserInfo = itr->second; } else { // not found StringStream msg; msg << "ServerGroupID : " << ServerGroupID; throw NoSuchElementException(msg.toString()); } return pUserInfo; __END_CATCH }
NKRecord * SubkeyListRecord::getSubkey(const std::wstring& name) const { NKRecord::NKRecordPtr foundRecord = NULL; NKRecord::NKRecordPtrList subKeys = getSubkeys(); NKRecord::NKRecordPtrList::iterator nkIter = subKeys.begin(); for (; nkIter != subKeys.end(); ++nkIter) { if (_wcsicmp(name.c_str(), (*nkIter)->getName().c_str()) == 0) { // Create a copy of the record to return as the records // in the list will be deleted. foundRecord = new NKRecord(*(*nkIter)); break; } } // Free the list of records. for (nkIter = subKeys.begin(); nkIter != subKeys.end(); ++nkIter) { delete *nkIter; } if (foundRecord == NULL) { throw NoSuchElementException("Failed to find subkey."); } return foundRecord; }
//-------------------------------------------------------------------------------- // get zone from zone manager //-------------------------------------------------------------------------------- ZoneGroup* ZoneGroupManager::getZoneGroup (ZoneGroupID_t zoneID) const throw(NoSuchElementException) { __BEGIN_TRY ZoneGroup* pZoneGroup = NULL; map< ZoneGroupID_t , ZoneGroup *>::const_iterator itr = m_ZoneGroups.find(zoneID); if (itr != m_ZoneGroups.end()) { pZoneGroup = itr->second; } else { // 그런 존 아이디를 찾을 수 없었을 때 StringStream msg; msg << "ZoneGroupID : " << zoneID; throw NoSuchElementException(msg.toString()); } return pZoneGroup; __END_CATCH }
//-------------------------------------------------------------------------------- // Delete zone from zone manager //-------------------------------------------------------------------------------- void ZoneGroupManager::deleteZoneGroup (ZoneGroupID_t zoneID) throw(NoSuchElementException) { __BEGIN_TRY map< ZoneGroupID_t , ZoneGroup *>::iterator itr = m_ZoneGroups.find(zoneID); if (itr != m_ZoneGroups.end()) { // 존을 삭제한다. SAFE_DELETE(itr->second); // pair를 삭제한다. m_ZoneGroups.erase(itr); } else { // 그런 존 아이디를 찾을 수 없었을 때 StringStream msg; msg << "ZoneGroupID : " << zoneID; throw NoSuchElementException(msg.toString()); } __END_CATCH }
const valueType & Map<keyType, valueType>::get (const keyType & key) const { if(this->size() == 0) { throw NoSuchElementException(); } MapItem<keyType, valueType> *curr = head; while(curr->key != key && curr != tail) { curr = curr->next; } if(curr->key == key) { return curr->value; } throw NoSuchElementException(); }
void GameServerGroupInfoManager::deleteGameServerGroupInfo(const ServerGroupID_t GroupID, WorldID_t WorldID) throw(NoSuchElementException) { __BEGIN_TRY HashMapGameServerGroupInfo::iterator itr = m_GameServerGroupInfos[WorldID].find(GroupID); if (itr != m_GameServerGroupInfos[WorldID].end()) { delete itr->second; m_GameServerGroupInfos[WorldID].erase(itr); } else throw NoSuchElementException("[GameServerGroupInfoManager] Gameserver Group not found to delete."); __END_CATCH }
int next() { if (!hasNext()) { throw NoSuchElementException("All nodes have been visited!"); } TreeNode res = stack.pop(); if (!stack.isEmpty()) { TreeNode top = stack.peek(); if (res == top->left) { findNextLeaf(top->right); // find next leaf in right sub-tree } } return res->val; }
Object* Sector::getObject(ObjectID_t id) throw(NoSuchElementException, Error) { __BEGIN_TRY map<ObjectID_t, Object*>::iterator itr = m_Objects.find(id); if (itr == m_Objects.end()) { cerr << "Sector::getObjectID() : NoSuchElementException" << endl; throw NoSuchElementException(); } return itr->second; __END_CATCH }
void Sector::deleteObject(ObjectID_t id) throw(NoSuchElementException, Error) { __BEGIN_TRY map<ObjectID_t, Object*>::iterator itr = m_Objects.find(id); if (itr == m_Objects.end()) { cerr << "Sector::deleteObjectID() : NoSuchElementException" << endl; throw NoSuchElementException(); } m_Objects.erase(itr); __END_CATCH }
const valueType & Map<keyType, valueType>::getCurrentValue () const { if(current != nullptr) return current->value; throw NoSuchElementException (); }