1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// hash_map_op_lt.cpp
// compile with: /EHsc
#define _DEFINE_DEPRECATED_HASH_CLASSES 0
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map<int, int> hm1, hm2, hm3;
hash_map <int, int>::iterator hm1_Iter, hm2_Iter, hm3_Iter;
int i;
typedef pair<int, int> Int_Pair;
for ( i = 1 ; i < 4 ; i++ )
{
hm1.insert ( Int_Pair ( i , i ) );
hm2.insert ( Int_Pair ( i , i + 1 ) );
hm3.insert ( Int_Pair ( i + 1 , i ) );
}
cout << "The elements of hash_map hm1 are:";
for ( hm1_Iter= hm1.begin( ) ; hm1_Iter!= hm1.end( ) ; hm1_Iter++)
cout << "( " << hm1_Iter-> first << ", " << hm1_Iter->second << " ) ";
cout << "." << endl;
cout << "The elements of hash_map hm2 are:";
for ( hm2_Iter= hm2.begin( ) ; hm2_Iter!= hm2.end( ) ; hm2_Iter++)
cout << "( " << hm2_Iter-> first << ", " << hm2_Iter->second << " ) ";
cout << "." << endl;
cout << "The elements of hash_map hm3 are:";
for ( hm3_Iter= hm3.begin( ) ; hm3_Iter!= hm3.end( ) ; hm3_Iter++)
cout << "( " << hm3_Iter-> first << ", " << hm3_Iter->second << " ) ";
cout << "." << endl;
if ( hm1 < hm2 )
cout << "The hash_map hm1 is less than the hash_map hm2." << endl;
else
cout << "The hash_map hm1 is not less than the hash_map hm2." << endl;
if ( hm1 < hm3 )
cout << "The hash_map hm1 is less than the hash_map hm3." << endl;
else
cout << "The hash_map hm1 is not less than the hash_map hm3." << endl;
} |
Partager