【正文】
ts inserted. Use hash_map? ? Hashed associative containers are optimized for the operations of lookup, insertion and removal. ? Hash_multimap ? hash_set ? hash_multiset 定義、插入、遍歷、刪除、查詢 include hash_map include iostream int main( ) { using namespace std。 using namespace stdext。 hash_map int, int::iterator hm1_pIter, hm2_pIter。 hash_map int, int hm1, hm2。 typedef pair int, int Int_Pair。 ( Int_Pair ( 1, 10 ) )。 ( Int_Pair ( 2, 20 ) )。 ( Int_Pair ( 3, 30 ) )。 ( Int_Pair ( 4, 40 ) )。 cout The original key/values of hm1 =。 for ( hm1_pIter = ( )。 hm1_pIter != ( )。 hm1_pIter++ ) { cout hm1_pIter first。 cout hm1_pIter second。 cout . endl。 } // If no match is found for the key, end( ) is returned hm1_RcIter = ( 4 )。 if ( hm1_RcIter == ( ) ) cout The hash_map hm1 doesn39。t have an element with a key of 4. endl。 else cout The element of hash_map hm1 with a key of 4 is: hm1_RcIter second . endl。 // The function removes an element at a given position Iter1 = ++( )。 ( Iter1 )。 cout After the 2nd element is deleted, the hash_map hm1 is: 。 for ( pIter = ( ) 。 pIter != ( ) 。 pIter++ ) cout pIter second。 cout . endl。 }