<map>
演算子
operator!=
演算子の左辺の map オブジェクトが右辺の map オブジェクトと等しくないかどうかを調べます。
bool operator!=(
const map <Key, Type, Traits, Allocator>& left,
const map <Key, Type, Traits, Allocator>& right);
パラメーター
left
map
型オブジェクト。
right
map
型オブジェクト。
戻り値
map が等しくない場合は true
、map が等しい場合はfalse
。
解説
map オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの map は、同じ数の要素を持ち、各要素の値が同じである場合に等しくなります。 それ以外の場合は等しくありません。
例
// map_op_ne.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map <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 << "The maps m1 and m2 are not equal." << endl;
else
cout << "The maps m1 and m2 are equal." << endl;
if ( m1 != m3 )
cout << "The maps m1 and m3 are not equal." << endl;
else
cout << "The maps m1 and m3 are equal." << endl;
}
The maps m1 and m2 are not equal.
The maps m1 and m3 are equal.
operator<
演算子の左辺の map オブジェクトが右辺の map オブジェクトより小さいかどうかを調べます。
bool operator<(
const map <Key, Type, Traits, Allocator>& left,
const map <Key, Type, Traits, Allocator>& right);
パラメーター
left
map
型オブジェクト。
right
map
型オブジェクト。
戻り値
演算子の左辺の map が演算子の右辺の map より厳密に小さい場合は true
、それ以外の場合は false
。
解説
map オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の小なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// map_op_lt.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map<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 map m1 is less than the map m2." << endl;
else
cout << "The map m1 is not less than the map m2." << endl;
if ( m1 < m3 )
cout << "The map m1 is less than the map m3." << endl;
else
cout << "The map m1 is not less than the map m3." << endl;
}
The map m1 is less than the map m2.
The map m1 is not less than the map m3.
operator<=
演算子の左辺の map オブジェクトが右辺の map オブジェクト以下かどうかを調べます。
bool operator<=(
const map <Key, Type, Traits, Allocator>& left,
const map <Key, Type, Traits, Allocator>& right);
パラメーター
left
map
型オブジェクト。
right
map
型オブジェクト。
戻り値
演算子の左辺の map が演算子の右辺の map 以下である場合は true
、それ以外の場合は false
。
例
// map_op_le.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map <int, int> m1, m2, m3, m4;
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 ) );
m4.insert ( Int_Pair ( i, i ) );
}
if ( m1 <= m2 )
cout << "The map m1 is less than or equal to the map m2." << endl;
else
cout << "The map m1 is greater than the map m2." << endl;
if ( m1 <= m3 )
cout << "The map m1 is less than or equal to the map m3." << endl;
else
cout << "The map m1 is greater than the map m3." << endl;
if ( m1 <= m4 )
cout << "The map m1 is less than or equal to the map m4." << endl;
else
cout << "The map m1 is greater than the map m4." << endl;
}
The map m1 is less than or equal to the map m2.
The map m1 is greater than the map m3.
The map m1 is less than or equal to the map m4.
operator==
演算子の左辺の map オブジェクトが右辺の map オブジェクトと等しいかどうかを調べます。
bool operator==(
const map <Key, Type, Traits, Allocator>& left,
const map <Key, Type, Traits, Allocator>& right);
パラメーター
left
map
型オブジェクト。
right
map
型オブジェクト。
戻り値
演算子の左辺の map が演算子の右辺の map と等しい場合は true
、それ以外の場合は false
。
解説
map オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの map は、同じ数の要素を持ち、各要素の値が同じである場合に等しくなります。 それ以外の場合は等しくありません。
例
// map_op_eq.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map < 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 << "The maps m1 and m2 are equal." << endl;
else
cout << "The maps m1 and m2 are not equal." << endl;
if ( m1 == m3 )
cout << "The maps m1 and m3 are equal." << endl;
else
cout << "The maps m1 and m3 are not equal." << endl;
}
The maps m1 and m2 are not equal.
The maps m1 and m3 are equal.
operator>
演算子の左辺の map オブジェクトが右辺の map オブジェクトより大きいかどうかを調べます。
bool operator>(
const map <Key, Type, Traits, Allocator>& left,
const map <Key, Type, Traits, Allocator>& right);
パラメーター
left
map
型オブジェクト。
right
map
型オブジェクト。
戻り値
演算子の左辺の map が演算子の右辺の map より大きい場合は true
、それ以外の場合は false
。
解説
map オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の大なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// map_op_gt.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map < 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 - 1 ) );
}
if ( m1 > m2 )
cout << "The map m1 is greater than the map m2." << endl;
else
cout << "The map m1 is not greater than the map m2." << endl;
if ( m1 > m3 )
cout << "The map m1 is greater than the map m3." << endl;
else
cout << "The map m1 is not greater than the map m3." << endl;
}
/* Output:
The map m1 is not greater than the map m2.
The map m1 is greater than the map m3.
*/
operator>=
演算子の左辺の map オブジェクトが右辺の map オブジェクト以上かどうかを調べます。
bool operator>=(
const map <Key, Type, Traits, Allocator>& left,
const map <Key, Type, Traits, Allocator>& right);
パラメーター
left
map
型オブジェクト。
right
map
型オブジェクト。
戻り値
演算子の左側の map がリストの右側の map 以上の場合は true
、それ以外の場合は false
。
例
// map_op_ge.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map < int, int > m1, m2, m3, m4;
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 ) );
m4.insert ( Int_Pair ( i, i ) );
}
if ( m1 >= m2 )
cout << "Map m1 is greater than or equal to map m2." << endl;
else
cout << "The map m1 is less than the map m2." << endl;
if ( m1 >= m3 )
cout << "Map m1 is greater than or equal to map m3." << endl;
else
cout << "The map m1 is less than the map m3." << endl;
if ( m1 >= m4 )
cout << "Map m1 is greater than or equal to map m4." << endl;
else
cout << "The map m1 is less than the map m4." << endl;
}
The map m1 is less than the map m2.
Map m1 is greater than or equal to map m3.
Map m1 is greater than or equal to map m4.
operator!= (multimap)
演算子の左辺の multimap オブジェクトが右辺の multimap オブジェクトと等しくないかどうかをテストします。
bool operator!=(
const multimap <Key, Type, Traits, Allocator>& left,
const multimap <Key, Type, Traits, Allocator>& right);
パラメーター
left
multimap
型オブジェクト。
right
multimap
型オブジェクト。
戻り値
multimap が等しくない場合は true
、multimap が等しい場合は false
。
解説
multimap オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの multimap は、同じ数の要素を持ち各要素の値が同じである場合に、等しくなります。 それ以外の場合は等しくありません。
例
// multimap_op_ne.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 << "The multimaps m1 and m2 are not equal." << endl;
else
cout << "The multimaps m1 and m2 are equal." << endl;
if ( m1 != m3 )
cout << "The multimaps m1 and m3 are not equal." << endl;
else
cout << "The multimaps m1 and m3 are equal." << endl;
}
The multimaps m1 and m2 are not equal.
The multimaps m1 and m3 are equal.
operator<
(multimap)
演算子の左辺の multimap オブジェクトが右辺の multimap オブジェクトより小さいかどうかをテストします。
bool operator<(
const multimap <Key, Type, Traits, Allocator>& left,
const multimap <Key, Type, Traits, Allocator>& right);
パラメーター
left
multimap
型オブジェクト。
right
multimap
型オブジェクト。
戻り値
演算子の左辺の multimap が演算子の右辺の multimap より厳密に小さい場合は true
、それ以外の場合は false
。
解説
multimap オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の小なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// 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;
}
The multimap m1 is less than the multimap m2.
The multimap m1 is not less than the multimap m3.
operator<=
(multimap)
演算子の左辺の multimap オブジェクトが右辺の multimap オブジェクト以下かどうかをテストします。
bool operator<=(
const multimap <Key, Type, Traits, Allocator>& left,
const multimap <Key, Type, Traits, Allocator>& right);
パラメーター
left
multimap
型オブジェクト。
right
multimap
型オブジェクト。
戻り値
演算子の左辺の multimap が演算子の右辺の multimap 以下の場合は true
、それ以外の場合は false
。
例
// multimap_op_le.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
multimap <int, int> m1, m2, m3, m4;
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 ) );
m4.insert ( Int_Pair ( i, i ) );
}
if ( m1 <= m2 )
cout << "m1 is less than or equal to m2" << endl;
else
cout << "m1 is greater than m2" << endl;
if ( m1 <= m3 )
cout << "m1 is less than or equal to m3" << endl;
else
cout << "m1 is greater than m3" << endl;
if ( m1 <= m4 )
cout << "m1 is less than or equal to m4" << endl;
else
cout << "m1 is greater than m4" << endl;
}
m1 is less than or equal to m2
m1 is greater than m3
m1 is less than or equal to m4
operator== (multimap)
演算子の左辺の multimap オブジェクトが右辺の multimap オブジェクトと等しいかどうかをテストします。
bool operator==(
const multimap <Key, Type, Traits, Allocator>& left,
const multimap <Key, Type, Traits, Allocator>& right);
パラメーター
left
multimap
型オブジェクト。
right
multimap
型オブジェクト。
戻り値
演算子の左辺の multimap が演算子の右辺の multimap と等しい場合は true
、それ以外の場合は false
。
解説
multimap オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの multimap は、同じ数の要素を持ち各要素の値が同じである場合に、等しくなります。 それ以外の場合は等しくありません。
例
// 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;
}
m1 and m2 are not equal
m1 and m3 are equal
operator>
(multimap)
演算子の左辺の multimap オブジェクトが右辺の multimap オブジェクトより大きいかどうかをテストします。
bool operator>(
const multimap <Key, Type, Traits, Allocator>& left,
const multimap <Key, Type, Traits, Allocator>& right);
パラメーター
left
multimap
型オブジェクト。
right
multimap
型オブジェクト。
戻り値
演算子の左辺の multimap が演算子の右辺の multimap より大きい場合は true
、それ以外の場合は false
。
解説
multimap オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の大なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// multimap_op_gt.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 - 1 ) );
}
if ( m1 > m2 )
cout << "The multimap m1 is greater than the multimap m2." << endl;
else
cout << "Multimap m1 is not greater than multimap m2." << endl;
if ( m1 > m3 )
cout << "The multimap m1 is greater than the multimap m3." << endl;
else
cout << "The multimap m1 is not greater than the multimap m3." << endl;
}
Multimap m1 is not greater than multimap m2.
The multimap m1 is greater than the multimap m3.
operator>=
(multimap)
演算子の左辺の multimap オブジェクトが右辺の multimap オブジェクト以上かどうかをテストします。
bool operator>=(
const multimap <Key, Type, Traits, Allocator>& left,
const multimap <Key, Type, Traits, Allocator>& right);
パラメーター
left
multimap
型オブジェクト。
right
multimap
型オブジェクト。
戻り値
演算子の左側の multimap がリストの右側の multimap 以上の場合は true
、それ以外の場合は false
。
例
// multimap_op_ge.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
multimap < int, int > m1, m2, m3, m4;
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 ) );
m4.insert ( Int_Pair ( i, i ) );
}
if ( m1 >= m2 )
cout << "The multimap m1 is greater than or equal to the multimap m2." << endl;
else
cout << "The multimap m1 is less than the multimap m2." << endl;
if ( m1 >= m3 )
cout << "The multimap m1 is greater than or equal to the multimap m3." << endl;
else
cout << "The multimap m1 is less than the multimap m3." << endl;
if ( m1 >= m4 )
cout << "The multimap m1 is greater than or equal to the multimap m4." << endl;
else
cout << "The multimap m1 is less than the multimap m4." << endl;
}
The multimap m1 is less than the multimap m2.
The multimap m1 is greater than or equal to the multimap m3.
The multimap m1 is greater than or equal to the multimap m4.