共用方式為


multimap::key_comp

擷取在 multimap 用來命令索引鍵比較物件的複本。

key_compare key_comp( ) const;

傳回值

傳回 multimap 使用排序其項目的函式物件。

備註

在屬性中定義的成員函式。

bool operatorconst Key&(xy)const Key&

要傳回 true,如果 x 完全 Y 優先 順序排序次序。

範例

// multimap_key_comp.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;
   
   multimap <int, int, less<int> > m1;
   multimap <int, int, less<int> >::key_compare kc1 = m1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )   
   {
      cout << "kc1( 2,3 ) returns value of true, "
           << "where kc1 is the function object of m1."
           << endl;
   }
   else   
   {
      cout << "kc1( 2,3 ) returns value of false "
           << "where kc1 is the function object of m1."
           << endl;
   }

   multimap <int, int, greater<int> > m2;
   multimap <int, int, greater<int> >::key_compare kc2 = m2.key_comp( );
   bool result2 = kc2( 2, 3 ) ;
   if( result2 == true )   
   {
      cout << "kc2( 2,3 ) returns value of true, "
           << "where kc2 is the function object of m2."
           << endl;
   }
   else   
   {
      cout << "kc2( 2,3 ) returns value of false, "
           << "where kc2 is the function object of m2."
           << endl;
   }
}
  
  

需求

標題: <map>

命名空間: std

請參閱

參考

multimap Class

標準樣板程式庫