hash_multimap::key_comp
[!NOTA]
Questo API è obsoleto.L'alternativa consiste unordered_multimap Class.
Recupera una copia dell'oggetto di confronto utilizzato alle chiavi di ordinamento in un hash_multimap.
key_compare key_comp( ) const;
Valore restituito
Restituisce l'oggetto funzione che un hash_multimap utilizza per ordinare gli elementi.
Note
L'oggetto memorizzato definisce la funzione membro
bool operator(const Key& _Left**, const Key&** _Right**);**
quali restituisce true se _Left precede e non è uguale a _Right ordinati.
In Visual C++ .NET 2003, i membri dei file di intestazione <hash_set> e <hash_map> non sono più nello spazio dei nomi di deviazione standard, ma sono stati spostati nello spazio dei nomi di stdext.Per ulteriori informazioni, vedere lo spazio dei nomi stdext.
Esempio
// hash_multimap_key_comp.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multimap <int, int, hash_compare<int, less<int> > > hm1;
hash_multimap <int, int, hash_compare<int, less<int> >
>::key_compare kc1 = hm1.key_comp( ) ;
bool result1 = kc1( 2, 3 ) ;
if( result1 == true )
{
cout << "kc1( 2,3 ) returns value of true,\n"
<< "where kc1 is the function object of hm1.\n"
<< endl;
}
else
{
cout << "kc1( 2,3 ) returns value of false,\n"
<< "where kc1 is the function object of hm1.\n"
<< endl;
}
hash_multimap <int, int, hash_compare<int, greater<int> > > hm2;
hash_multimap <int, int, hash_compare<int, greater<int> >
>::key_compare kc2 = hm2.key_comp( );
bool result2 = kc2( 2, 3 ) ;
if( result2 == true )
{
cout << "kc2( 2,3 ) returns value of true,\n"
<< "where kc2 is the function object of hm2."
<< endl;
}
else
{
cout << "kc2( 2,3 ) returns value of false,\n"
<< "where kc2 is the function object of hm2."
<< endl;
}
}
Output
kc1( 2,3 ) returns value of true,
where kc1 is the function object of hm1.
kc2( 2,3 ) returns value of false,
where kc2 is the function object of hm2.
Requisiti
intestazione: <hash_map>
Stdext diSpazio dei nomi: