hash_multimap::key_comp
[!POZNÁMKA]
Toto rozhraní API je zastaralé.Alternativou je unordered_multimap – třída.
Získá kopii porovnání objekt použitý k pořadí klíče hash_multimap.
key_compare key_comp( ) const;
Vrácená hodnota
Vrátí funkce objekt, který používá hash_multimap objednání jeho prvků.
Poznámky
Definuje objekt uložené členskou funkci
bool operator(const Key&_Left**, const Key&_Right);**
která vrátí true li _Left předchází a není rovno _Right v pořadí řazení.
V aplikaci Visual C++ .NET 2003, členové hlavičkových souborů tříd <hash_map> a <hash_set> již nejsou v oboru názvů std, ale byly přesunuty do oboru názvů stdext.Další informace naleznete v tématu Obor názvů stdext.
Příklad
// 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;
}
}
Výsledek
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.
Požadavky
Hlavička: <hash_map>
Obor názvů: stdext