📄 transfer_char_to_key.cpp
字号:
#include <iostream>
#include <hash_map>
#include <string>
using namespace std;
using namespace stdext;
template <>
bool hash_compare<int>::operator( ) (
const int & s1,
const int & s2
) const
{
char *ss1 = (char*)(s1);
char *ss2 = (char*)(s2);
if (strcmp(ss1,ss2) == 0)
return false;
else
return true;
}
int main(int argc,char** argv )
{
hash_map <int, int, hash_compare <int > > hm;
hash_map <int, int, hash_compare <int > >::iterator itp1;
char* s1 = strdup("111");
char* s2 = strdup("222");
hm[(int)(s1)] = 111;
hm[(int)(s2)] = 222;
char* key1 = strdup("111");
itp1 = hm.find((int)(key1));
if (itp1 == hm.end()) {
cout<<"not found "<<key1<<endl;
}
else {
cout<<"found :"<<key1<<" == "<<itp1->second<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -