uthash_learn.c
来自「在LINUX下实现对哈希表的操作」· C语言 代码 · 共 34 行
C
34 行
#include <hash_map.h>
#include <iostream.h>
#include <string.h>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, string> hm1;
hash_map <int, string> :: iterator hm1_Iter;
hash_map <int, string> :: const_iterator hm1_cIter;
typedef pair <int, string> Int_Pair;
hm1.insert ( Int_Pair ( 0, "令狐冲" ) );
hm1.insert ( Int_Pair ( 1, "东方不败" ) );
hm1.insert ( Int_Pair ( 2, "任我行" ) );
hm1_cIter = hm1.begin ( );
cout << "The first element of hm1 is "
<< hm1_cIter -> first << "." << endl;
hm1_Iter = hm1.begin ( );
hm1.erase ( hm1_Iter );
// The following 2 lines would err because the iterator is const
// hm1_cIter = hm1.begin ( );
// hm1.erase ( hm1_cIter );
hm1_cIter = hm1.begin( );
cout << "The first element of hm1 is now "
<< hm1_cIter -> first << "." << endl;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?