Compartir a través de


hash_multimap::key_comp

[!NOTA]

Esta API está obsoleta.La alternativa es unordered_multimap Class.

Recupera una copia del objeto de comparación utilizado a claves ordenadas en un hash_multimap.

key_compare key_comp( ) const;

Valor devuelto

Devuelve el objeto function que un hash_multimap utiliza para ordenar los elementos.

Comentarios

El objeto almacenado define la función miembro

bool operator(const Key& _Left**, const Key&** _Right));

qué devuelve true si _Left precede y no es igual a _Right en el criterio de ordenación.

En Visual C++ .NET 2003, los miembros de los archivos de encabezado <hash_map> y <hash_set> ya no están en el espacio de nombres std, pero se han movido bastante al espacio de nombres stdext.Vea El espacio de nombres stdext para obtener más información.

Ejemplo

// 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.

Requisitos

Encabezado: <hash_map>

Stdext deEspacio de nombres:

Vea también

Referencia

hash_multimap Class

Biblioteca de plantillas estándar