本文整理汇总了C++中unordered_map::get方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::get方法的具体用法?C++ unordered_map::get怎么用?C++ unordered_map::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unordered_map
的用法示例。
在下文中一共展示了unordered_map::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: caseLogin
void caseLogin() {
int id=readbyte(0);
Player player = players.get(id);
player->name = readstring(0);
cout << "Player: " << player->name << " joined." << endl;
clearbuffer(0);
writebyte(3,0);
writebyte(id,0);
/*const char* name_1=player->name.c_str();
char* name=const_cast<char*>(name_1);*/
//^ string to char* conversion... change it to: &(player->name)[0]
writestring(&(player->name)[0],0);
sendAll(player);
for(auto it : players)
if((it->second) != player) {
clearbuffer(0);
writebyte(3,0);
writebyte((it->second)->id,0);
writestring(&(it->second->name)[0],0);
sendmessage(it->second->sock, "", 0, 0);
}
}
示例2: caseLeave
void caseLeave() {
int id=readbyte(0);
Player player = players.get(id);
cout << player->name << " has left." << endl;
clearbuffer(0);
writebyte(6,0);
writebyte(id,0);
writestring(&(player->name)[0],0);
sendAll(player);
closesock(player->sock);
}
示例3: caseEnter
void caseEnter() {
int id=readbyte(0);
Player player = players.get(id);
player->x = readshort(0);
player->y = readshort(0);
player->direction = readshort(0);
clearbuffer(0);
writebyte(5,0);
writebyte(id,0);
writeshort(player->x,0);
writeshort(player->y,0);
writeshort(player->direction,0);
sendAll(player);
}