operator< (hash_map)
Tests if the hash_map object on the left side of the operator is less than the hash_map object on the right side.
bool operator<(
const hash_map <Key, Type, Traits, Allocator>& _Left,
const hash_map <Key, Type, Traits, Allocator>& _Right
);
Parameters
_Left
An object of type hash_map._Right
An object of type hash_map.
Return Value
true if the hash_map on the left side of the operator is strictly less than the hash_map on the right side of the operator; otherwise false.
Remarks
The comparison between hash_map objects is based on a pairwise comparison of their elements. The less-than relationship between two objects is based on a comparison of the first pair of unequal elements.
In Visual C++ .NET 2003, members of the <hash_map> and <hash_set> header files are no longer in the std namespace, but rather have been moved into the stdext namespace. See The stdext Namespace for more information.
Example
// 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;
}
The elements of hash_map hm1 are:( 1, 1 ) ( 2, 2 ) ( 3, 3 ) . The elements of hash_map hm2 are:( 1, 2 ) ( 2, 3 ) ( 3, 4 ) . The elements of hash_map hm3 are:( 2, 1 ) ( 3, 2 ) ( 4, 3 ) . The hash_map hm1 is less than the hash_map hm2. The hash_map hm1 is less than the hash_map hm3.
Requirements
Header: <hash_map>
Namespace: stdext