Solution:
1. Import the hash_map class library in stl.
# include & lthash _ map & gt
Use namespace std
Use the namespace stdext
2.hash_map is an aggregation class.
It inherits from the _Hash class, including a vector, a list and a pair, where the vector is used to save bucket, the list is used for conflict handling, and the pair is used to save key->; Value structure, brief pseudo code is as follows:
class hash _ map & ltclass _Tkey,class _ Tval & gt
{
Private:
Typedef pair & lt_Tkey, _ Tval & gt hash pair;
Typedef list & lt hash pair & gthash _ list
Typedef vector & lthash _ list & gt hash _ table;
};
3. Examples of usage:
Hash _ map & ltint, int> intash;
in hash[ 1]= 123;
in hash[2]= 456;
int val = in hash[ 1];
int val = in hash[2];