operator== (multimap)
演算子の左側の map の map のオブジェクトが右側のオブジェクトと等しいかどうかを調べます。
bool operator==(
const multimap <Key, Type, Traits, Allocator>& _Left,
const multimap <Key, Type, Traits, Allocator>& _Right
);
パラメーター
_Left
multimap 型のオブジェクト。_Right
multimap 型のオブジェクト。
戻り値
演算子の左側の multimap が演算子の右側の multimap と等しいtrue ; それ false。
解説
map オブジェクトの間の比較は、要素のペアに比較に基づいています。2 個の multimaps は、要素の数が同じで、対応する要素の値が同じ同じです。それ以外の場合は等しくありません。
使用例
// multimap_op_eq.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 = 0; i < 3; i++)
{
m1.insert(Int_Pair(i, i));
m2.insert(Int_Pair(i, i*i));
m3.insert(Int_Pair(i, i));
}
if ( m1 == m2 )
cout << "m1 and m2 are equal" << endl;
else
cout << "m1 and m2 are not equal" << endl;
if ( m1 == m3 )
cout << "m1 and m3 are equal" << endl;
else
cout << "m1 and m3 are not equal" << endl;
}
必要条件
ヘッダー: <map>
名前空間: std