次の方法で共有


operator< (<queue>)

演算子の左側のキュー オブジェクトが右側のオブジェクトより小さいキュー テスト。

bool operator<(
   const queue <Type, Container>& _Left,
   const queue <Type, Container>& _Right,
);

パラメーター

  • _Left
    queue型のオブジェクト。

  • _Right
    queue型のオブジェクト。

戻り値

演算子の左側のキューによりも小さいと等しくないと演算子の右側のキューtrue ; それ false

解説

キュー オブジェクトの比較は、要素のペアに比較に基づいています。2 個のキュー オブジェクト間の関係も少ない最初のペアの付いていない要素の比較に基づいています。

使用例

// queue_op_lt.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>

int main( )
{
   using namespace std;

   // Declares queues with default deque base container
   queue <int> q1, q2, q3;

   q1.push( 1 );
   q1.push( 2 );
   q2.push( 5 );
   q2.push( 10 );
   q3.push( 1 );
   q3.push( 2 );

   if ( q1 < q2 )
      cout << "The queue q1 is less than the queue q2." << endl;
   else
      cout << "The queue q1 is not less than the queue q2." << endl;

   if ( q1 < q3 )
      cout << "The queue q1 is less than the queue q3." << endl;
   else
      cout << "The queue q1 is not less than the queue q3." << endl;
}
  
  

必要条件

ヘッダー: <queue>

名前空間: std

参照

関連項目

標準テンプレート ライブラリ