本文整理汇总了C++中TABLE::eraser方法的典型用法代码示例。如果您正苦于以下问题:C++ TABLE::eraser方法的具体用法?C++ TABLE::eraser怎么用?C++ TABLE::eraser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TABLE
的用法示例。
在下文中一共展示了TABLE::eraser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
void merge(ClientMap& clientMap, char ID[], char password[], char ID_2[], char password_2[], TABLE &id_table)
{
ClientData *clientData_1 = clientMap.search(ID);
ClientData *clientData_2 = clientMap.search(ID_2);
if (clientData_1 == nullptr){
printf("ID %s not found\n", ID);
return;
}
if (clientData_2 == nullptr){
printf("ID %s not found\n", ID_2);
return;
}
char encryptedPwd_1[110]; md5(encryptedPwd_1, password);
if (strcmp(clientData_1->md5_password, encryptedPwd_1) != 0){
printf("wrong password1\n");
return;
}
char encryptedPwd_2[110]; md5(encryptedPwd_2, password_2);
if (strcmp(clientData_2->md5_password, encryptedPwd_2) != 0){
printf("wrong password2\n");
return;
}
clientData_1->money += clientData_2->money;
mergeHistory(clientData_1->history, clientData_2->history);
char* tempID = id_table.eraser(clientData_2->IDpos, strlen(ID_2));
if (tempID != NULL){
ClientData *backID_clientData = clientMap.search(tempID);
backID_clientData->IDpos = clientData_2->IDpos;
}
clientMap.erase(ID_2);
printf("success, %s has %lld dollars\n", ID, clientData_1->money);
return;
}
示例2: remove
void remove(ClientMap& clientMap, char ID[], char plainPwd[], TABLE &id_table)
{
ClientData *clientData = clientMap.search(ID);
if (clientData == nullptr){
printf("ID %s not found\n", ID);
return;
}
char encryptedPwd[110]; md5(encryptedPwd, plainPwd);
if (strcmp(clientData->md5_password, encryptedPwd) == 0){
char* tempID = id_table.eraser(clientData->IDpos, strlen(ID));
if (tempID != NULL){
ClientData *clientData_2 = clientMap.search(tempID);
clientData_2->IDpos = clientData->IDpos;
}
clientMap.erase(ID);
printf("success\n");
}
else
printf("wrong password\n");
}