<set> 演算子
operator!= (set)
演算子の左辺の set オブジェクトが右辺の set オブジェクトと等しくないかどうかを調べます。
bool operator!=(const set <Key, Traits, Allocator>& left, const set <Key, Traits, Allocator>& right);
パラメーター
left
set 型のオブジェクト。
right
set 型のオブジェクト。
戻り値
set が等しくない場合は true、set が等しい場合は false。
注釈
set オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの set は、同じ数の要素を持ち、各要素の値が同じである場合に等しくなります。 それ以外の場合は等しくありません。
例
// set_op_ne.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int> s1, s2, s3;
int i;
for ( i = 0 ; i < 3 ; i++ )
{
s1.insert ( i );
s2.insert ( i * i );
s3.insert ( i );
}
if ( s1 != s2 )
cout << "The sets s1 and s2 are not equal." << endl;
else
cout << "The sets s1 and s2 are equal." << endl;
if ( s1 != s3 )
cout << "The sets s1 and s3 are not equal." << endl;
else
cout << "The sets s1 and s3 are equal." << endl;
}
/* Output:
The sets s1 and s2 are not equal.
The sets s1 and s3 are equal.
*/
operator< (set)
演算子の左辺の set オブジェクトが右辺の set オブジェクトより小さいかどうかを調べます。
bool operator<(const set <Key, Traits, Allocator>& left, const set <Key, Traits, Allocator>& right);
パラメーター
left
set 型のオブジェクト。
right
set 型のオブジェクト。
戻り値
演算子の左辺の set が演算子の右辺の set より厳密に小さい場合は true、それ以外の場合は false。
注釈
set オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の小なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// set_op_lt.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <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 set s1 is less than the set s2." << endl;
else
cout << "The set s1 is not less than the set s2." << endl;
if ( s1 < s3 )
cout << "The set s1 is less than the set s3." << endl;
else
cout << "The set s1 is not less than the set s3." << endl;
}
/* Output:
The set s1 is less than the set s2.
The set s1 is not less than the set s3.
*/
operator<= (set)
演算子の左辺の set オブジェクトが右辺の set オブジェクト以下かどうかを調べます。
bool operator!<=(const set <Key, Traits, Allocator>& left, const set <Key, Traits, Allocator>& right);
パラメーター
left
set 型のオブジェクト。
right
set 型のオブジェクト。
戻り値
演算子の左辺の set が演算子の右辺の set 以下である場合は true、それ以外の場合は false。
注釈
set オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の "以下" 関係は、最初の等しくない要素のペアの比較に基づいています。
例
// set_op_le.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int> s1, s2, s3, s4;
int i;
for ( i = 0 ; i < 3 ; i++ )
{
s1.insert ( i );
s2.insert ( i * i );
s3.insert ( i - 1 );
s4.insert ( i );
}
if ( s1 <= s2 )
cout << "Set s1 is less than or equal to the set s2." << endl;
else
cout << "The set s1 is greater than the set s2." << endl;
if ( s1 <= s3 )
cout << "Set s1 is less than or equal to the set s3." << endl;
else
cout << "The set s1 is greater than the set s3." << endl;
if ( s1 <= s4 )
cout << "Set s1 is less than or equal to the set s4." << endl;
else
cout << "The set s1 is greater than the set s4." << endl;
}
Set s1 is less than or equal to the set s2.
The set s1 is greater than the set s3.
Set s1 is less than or equal to the set s4.
operator== (set)
演算子の左辺の set オブジェクトが右辺の set オブジェクトと等しいかどうかを調べます。
bool operator!==(const set <Key, Traits, Allocator>& left, const set <Key, Traits, Allocator>& right);
パラメーター
left
set 型のオブジェクト。
right
set 型のオブジェクト。
戻り値
演算子の左辺の set が演算子の右辺の set と等しい場合は true、それ以外の場合は false。
注釈
set オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの set は、同じ数の要素を持ち、各要素の値が同じである場合に等しくなります。 それ以外の場合は等しくありません。
例
// set_op_eq.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int> s1, s2, s3;
int i;
for ( i = 0 ; i < 3 ; i++ )
{
s1.insert ( i );
s2.insert ( i * i );
s3.insert ( i );
}
if ( s1 == s2 )
cout << "The sets s1 and s2 are equal." << endl;
else
cout << "The sets s1 and s2 are not equal." << endl;
if ( s1 == s3 )
cout << "The sets s1 and s3 are equal." << endl;
else
cout << "The sets s1 and s3 are not equal." << endl;
}
The sets s1 and s2 are not equal.
The sets s1 and s3 are equal.
operator> (set)
演算子の左辺の set オブジェクトが右辺の set オブジェクトより大きいかどうかを調べます。
bool operator>(const set <Key, Traits, Allocator>& left, const set <Key, Traits, Allocator>& right);
パラメーター
left
set 型のオブジェクト。
right
set 型のオブジェクト。
戻り値
演算子の左辺の set が演算子の右辺の set より大きい場合は true、それ以外の場合は false。
注釈
set オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の大なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// set_op_gt.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <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 set s1 is greater than the set s2." << endl;
else
cout << "The set s1 is not greater than the set s2." << endl;
if ( s1 > s3 )
cout << "The set s1 is greater than the set s3." << endl;
else
cout << "The set s1 is not greater than the set s3." << endl;
}
/* Output:
The set s1 is not greater than the set s2.
The set s1 is greater than the set s3.
*/
operator>= (set)
演算子の左辺の set オブジェクトが右辺の set オブジェクト以上かどうかを調べます。
bool operator!>=(const set <Key, Traits, Allocator>& left, const set <Key, Traits, Allocator>& right);
パラメーター
left
set 型のオブジェクト。
right
set 型のオブジェクト。
戻り値
演算子の左辺の set が演算子の右辺の set 以上の場合は true、それ以外の場合は false。
注釈
set オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の "以上" 関係は、最初の等しくない要素のペアの比較に基づいています。
例
// set_op_ge.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int> s1, s2, s3, s4;
int i;
for ( i = 0 ; i < 3 ; i++ )
{
s1.insert ( i );
s2.insert ( i * i );
s3.insert ( i - 1 );
s4.insert ( i );
}
if ( s1 >= s2 )
cout << "Set s1 is greater than or equal to set s2." << endl;
else
cout << "The set s1 is less than the set s2." << endl;
if ( s1 >= s3 )
cout << "Set s1 is greater than or equal to set s3." << endl;
else
cout << "The set s1 is less than the set s3." << endl;
if ( s1 >= s4 )
cout << "Set s1 is greater than or equal to set s4." << endl;
else
cout << "The set s1 is less than the set s4." << endl;
}
The set s1 is less than the set s2.
Set s1 is greater than or equal to set s3.
Set s1 is greater than or equal to set s4.
operator!= (multiset)
演算子の左側の multiset のオブジェクトが、右側の multiset のオブジェクトと等しくないかどうかをテストします。
bool operator!=(const multiset <Key, Traits, Allocator>& left, const multiset <Key, Traits, Allocator>& right);
パラメーター
left
multiset 型のオブジェクト。
right
multiset 型のオブジェクト。
戻り値
set または multiset が等しくない場合は true、set または multiset が等しい場合は false。
注釈
multiset オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの set または multisets は、同じ数の要素を持ち、各要素の値が同じである場合に等しくなります。 それ以外の場合は等しくありません。
例
// multiset_op_ne.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 );
}
if ( s1 != s2 )
cout << "The multisets s1 and s2 are not equal." << endl;
else
cout << "The multisets s1 and s2 are equal." << endl;
if ( s1 != s3 )
cout << "The multisets s1 and s3 are not equal." << endl;
else
cout << "The multisets s1 and s3 are equal." << endl;
}
The multisets s1 and s2 are not equal.
The multisets s1 and s3 are equal.
operator< (multiset)
演算子の左側の multiset のオブジェクトが、右側の multiset のオブジェクト以下かどうかをテストします。
bool operator<(const multiset <Key, Traits, Allocator>& left, const multiset <Key, Traits, Allocator>& right);
パラメーター
left
multiset 型のオブジェクト。
right
multiset 型のオブジェクト。
戻り値
演算子の左辺の multiset が演算子の右辺の multiset より厳密に小さい場合は true、それ以外の場合は false。
注釈
multiset オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の小なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// 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;
}
The multiset s1 is less than the multiset s2.
The multiset s1 is not less than the multiset s3.
operator<= (multiset)
演算子の左側の multiset のオブジェクトが、右側の multiset のオブジェクト以下かどうかをテストします。
bool operator!<=(const multiset <Key, Traits, Allocator>& left, const multiset <Key, Traits, Allocator>& right);
パラメーター
left
multiset 型のオブジェクト。
right
multiset 型のオブジェクト。
戻り値
演算子の左辺の multiset が演算子の右辺の multiset 以下の場合は true、それ以外の場合は false。
注釈
multiset オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の "以下" 関係は、最初の等しくない要素のペアの比較に基づいています。
例
// multiset_op_le.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
multiset <int> s1, s2, s3, s4;
int i;
for ( i = 0 ; i < 3 ; i++ )
{
s1.insert ( i );
s2.insert ( i * i );
s3.insert ( i - 1 );
s4.insert ( i );
}
if ( s1 <= s2 )
cout << "The multiset s1 is less than "
<< "or equal to the multiset s2." << endl;
else
cout << "The multiset s1 is greater than "
<< "the multiset s2." << endl;
if ( s1 <= s3 )
cout << "The multiset s1 is less than "
<< "or equal to the multiset s3." << endl;
else
cout << "The multiset s1 is greater than "
<< "the multiset s3." << endl;
if ( s1 <= s4 )
cout << "The multiset s1 is less than "
<< "or equal to the multiset s4." << endl;
else
cout << "The multiset s1 is greater than "
<< "the multiset s4." << endl;
}
The multiset s1 is less than or equal to the multiset s2.
The multiset s1 is greater than the multiset s3.
The multiset s1 is less than or equal to the multiset s4.
operator== (multiset)
演算子の左側の multiset のオブジェクトが、右側の multiset のオブジェクトと等しいかどうかをテストします。
bool operator!==(const multiset <Key, Traits, Allocator>& left, const multiset <Key, Traits, Allocator>& right);
パラメーター
left
multiset 型のオブジェクト。
right
multiset 型のオブジェクト。
戻り値
演算子の左辺の multiset と演算子の右辺の multiset が等しい場合は true、それ以外の場合は false。
注釈
multiset オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つの set または multisets は、同じ数の要素を持ち、各要素の値が同じである場合に等しくなります。 それ以外の場合は等しくありません。
例
// multiset_op_eq.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 );
}
if ( s1 == s2 )
cout << "The multisets s1 and s2 are equal." << endl;
else
cout << "The multisets s1 and s2 are not equal." << endl;
if ( s1 == s3 )
cout << "The multisets s1 and s3 are equal." << endl;
else
cout << "The multisets s1 and s3 are not equal." << endl;
}
The multisets s1 and s2 are not equal.
The multisets s1 and s3 are equal.
operator> (multiset)
演算子の左側の multiset のオブジェクトが、右側の multiset のオブジェクトより大きいかどうかをテストします。
bool operator>(const multiset <Key, Traits, Allocator>& left, const multiset <Key, Traits, Allocator>& right);
パラメーター
left
multiset 型のオブジェクト。
right
multiset 型のオブジェクト。
戻り値
演算子の左辺の multiset が演算子の右辺の multiset より大きい場合は true、それ以外の場合は false。
注釈
multiset オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の大なり関係は、最初の等しくない要素のペアの比較に基づいています。
例
// multiset_op_gt.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 greater than "
<< "the multiset s2." << endl;
else
cout << "The multiset s1 is not greater "
<< "than the multiset s2." << endl;
if ( s1 > s3 )
cout << "The multiset s1 is greater than "
<< "the multiset s3." << endl;
else
cout << "The multiset s1 is not greater than "
<< "the multiset s3." << endl;
}
The multiset s1 is not greater than the multiset s2.
The multiset s1 is greater than the multiset s3.
operator>= (multiset)
演算子の左側の multiset のオブジェクトが、右側の multiset のオブジェクトより大きいかどうかをテストします。
bool operator!>=(const multiset <Key, Traits, Allocator>& left, const multiset <Key, Traits, Allocator>& right);
パラメーター
left
multiset 型のオブジェクト。
right
multiset 型のオブジェクト。
戻り値
演算子の左辺の multiset が演算子の右辺の multiset 以上の場合は true、それ以外の場合は false。
注釈
multiset オブジェクト間の比較は、要素のペアの比較に基づいています。 2 つのオブジェクト間の "以上" 関係は、最初の等しくない要素のペアの比較に基づいています。
例
// multiset_op_ge.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
multiset <int> s1, s2, s3, s4;
int i;
for ( i = 0 ; i < 3 ; i++ )
{
s1.insert ( i );
s2.insert ( i * i );
s3.insert ( i - 1 );
s4.insert ( i );
}
if ( s1 >= s2 )
cout << "The multiset s1 is greater than "
<< "or equal to the multiset s2." << endl;
else
cout << "The multiset s1 is less than "
<< "the multiset s2." << endl;
if ( s1 >= s3 )
cout << "The multiset s1 is greater than "
<< "or equal to the multiset s3." << endl;
else
cout << "The multiset s1 is less than "
<< "the multiset s3." << endl;
if ( s1 >= s4 )
cout << "The multiset s1 is greater than "
<< "or equal to the multiset s4." << endl;
else
cout << "The multiset s1 is less than "
<< "the multiset s4." << endl;
}
The multiset s1 is less than the multiset s2.
The multiset s1 is greater than or equal to the multiset s3.
The multiset s1 is greater than or equal to the multiset s4.