共用方式為


operator< (multiset)

測試,如果在運算子左方的多重集物件小於右邊的多重集物件。

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

參數

  • _Left
    型別 multiset 的物件。

  • _Right
    型別 multiset 的物件。

傳回值

true ,如果在運算子左方的多重集明顯小於多重集在運算子右方的;否則 false

備註

在多重集物件之間的比較可能會依據其項目比較配對。 小於比較兩個物件之間的關聯性會根據第一個要比較不相等的項目。

範例

// multiset_op_lt.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   multiset <int> s1, s2, s3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      s1.insert ( i );
      s2.insert ( i * i );
      s3.insert ( i - 1 );
   }

   if ( s1 < s2 )
      cout << "The multiset s1 is less than "
           << "the multiset s2." << endl;
   else
      cout << "The multiset s1 is not less than "
           << "the multiset s2." << endl;

   if ( s1 < s3 )
      cout << "The multiset s1 is less than "
           << "the multiset s3." << endl;
   else
      cout << "The multiset s1 is not less than "
           << "the multiset s3." << endl;
}
  

需求

標頭: <set>

命名空間: std

請參閱

參考

標準樣板程式庫