名前空間
変種
操作

operator==,!=,<,<=,>,>=,<=>(std::multimap)

提供: cppreference.com
< cpp‎ | container‎ | multimap
 
 
 
 
ヘッダ <map> で定義
template<class Key, class T, class Compare, class Alloc >

bool operator==(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                 conststd::multimap<Key,T,Compare,Alloc>& rhs );
(1)
template<class Key, class T, class Compare, class Alloc >

bool operator!=(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                 conststd::multimap<Key,T,Compare,Alloc>& rhs );
(2) (C++20未満)
template<class Key, class T, class Compare, class Alloc >

bool operator<(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                conststd::multimap<Key,T,Compare,Alloc>& rhs );
(3) (C++20未満)
template<class Key, class T, class Compare, class Alloc >

bool operator<=(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                 conststd::multimap<Key,T,Compare,Alloc>& rhs );
(4) (C++20未満)
template<class Key, class T, class Compare, class Alloc >

bool operator>(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                conststd::multimap<Key,T,Compare,Alloc>& rhs );
(5) (C++20未満)
template<class Key, class T, class Compare, class Alloc >

bool operator>=(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                 conststd::multimap<Key,T,Compare,Alloc>& rhs );
(6) (C++20未満)
template<class Key, class T, class Compare, class Alloc >

/* see below */ operator<=>(conststd::multimap<Key,T,Compare,Alloc>& lhs,

                             conststd::multimap<Key,T,Compare,Alloc>& rhs );
(7) (C++20以上)

2つの multimap の内容を比較します。

1-2)lhsrhs の内容が等しいかどうか調べます。 つまり、それらが同じ個数の要素を持ち、 lhs 内のそれぞれの要素が rhs 内の同じ位置の要素と等しいかどうか比較します。
3-6)lhsrhs の内容を辞書的に比較します。 比較は std::lexicographical_compare と同等の関数によって行われます。 この比較は multimap の順序 Compare を無視します。
7)lhsrhs の内容を辞書的に比較します。 比較は合成された三項比較 (後述) を行う関数オブジェクトを用いて2つの multimap に対して std::lexicographical_compare_three_way を呼んだかのように行われます。 戻り値の型は合成された三項比較の結果の型と同じです。 この比較は multimap の順序 Compare を無視します。 2つの const E 左辺値 lhs および rhs がそれぞれ左の被演算子および右の被演算子として与えられたとき (ただし Estd::pair<const Key, T> です)、合成された三項比較は以下のように定義されます。
  • std::three_way_comparable_with<E, E> が満たされる場合は、 lhs <=> rhs と同等です。
  • そうでなく、2つの const E 左辺値の < 演算子による比較が well-formed であり結果の型が boolean-testable の場合は、以下と同等です。
lhs < rhs ? std::weak_ordering::less: rhs < lhs ? std::weak_ordering::greater: std::weak_ordering::equivalent
  • そうでなければ、合成された三項比較は定義されず、 operator<=> はオーバーロード解決に参加しません。
three_way_comparable_with または boolean-testable が満たされないかモデル化されない場合、または < 演算子が使用されるけれども E< が全順序を確立しない場合、 operator<=> の動作は未定義です。

[編集]引数

lhs, rhs - 内容を比較する multimap
-
オーバロード (1-2) を使用するためには T, KeyEqualityComparable の要件を満たさなければなりません。
-
オーバロード (3-6) を使用するためには KeyLessThanComparable の要件を満たさなければなりません。 順序関係は全順序を確立しなければなりません。

[編集]戻り値

1)multimap の内容が等しい場合は true、そうでなければ false
2)multimap の内容が等しくない場合は true、そうでなければ false
3)lhs の内容が rhs の内容より辞書的に小さい場合は true、そうでなければ false
4)lhs の内容が rhs の内容より辞書的に小さいまたは等しい場合は true、そうでなければ false
5)lhs の内容が rhs の内容より辞書的に大きい場合は true、そうでなければ false
6)lhs の内容が rhs の内容より辞書的に大きいまたは等しい場合は true、そうでなければ false
7)lhs の内容が rhs の内容より辞書的に小さい場合は std::strong_ordering::less
lhs の内容が rhs の内容より辞書的に大きい場合は std::strong_ordering::greater
lhsrhs の同等でない最初の要素が順序付けできない場合は std::partial_ordering::unordered
そうでなければ std::strong::equal

[編集]計算量

1-2)lhsrhs のサイズが異なる場合は定数、そうでなければ multimap のサイズに線形
3-7)multimap のサイズに線形
close