operator< (multimap)

测试,如果运算符左侧的 multimap 对象比右侧的 multimap 对象较少。

bool operator<( 
   const multimap <Key, Type, Traits, Allocator>& _Left, 
   const multimap <Key, Type, Traits, Allocator>& _Right 
);

参数

  • _Left
    multimap 类型的对象。

  • _Right
    multimap 类型的对象。

返回值

true,如果运算符左侧的 multimap 比与运算符右侧的 multimap 严格小于;为 false

备注

在 multimap 对象之间的比较基于元素的一种比较成对。 小于两个对象之间的关系。根据第一个不相等对比较元素。

示例

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

int main( )
{
   using namespace std;
   multimap < int, int > m1, m2, m3;
   int i;
   typedef pair < int, int > Int_Pair;

   for ( i = 1 ; i < 3 ; i++ )
   {
      m1.insert ( Int_Pair ( i, i ) );
      m2.insert ( Int_Pair ( i, i * i ) );
      m3.insert ( Int_Pair ( i, i - 1 ) );
   }

   if ( m1 < m2 )
      cout << "The multimap m1 is less than the multimap m2." << endl;
   else
      cout << "The multimap m1 is not less than the multimap m2." << endl;

   if ( m1 < m3 )
      cout << "The multimap m1 is less than the multimap m3." << endl;
   else
      cout << "The multimap m1 is not less than the multimap m3." << endl;
}
  

要求

标头: <map>

命名空间: std

请参见

参考

标准模板库