Namespaces
Variants

std::experimental::ranges:: is_permutation

From cppreference.net
HTMLタグ、属性、C++コード、C++専門用語はすべて原文のまま保持し、必要な部分のみ日本語に翻訳しました。 (注:このHTML要素には翻訳対象のテキストコンテンツが含まれていないため、元の構造をそのまま保持しています)
template < ForwardIterator I1, Sentinel < I1 > S1, ForwardIterator I2, Sentinel < I2 > S2,

class Pred = ranges:: equal_to <> ,
class Proj1 = ranges:: identity , class Proj2 = ranges:: identity >
requires IndirectlyComparable < I1, I2, Pred, Proj1, Proj2 >
bool is_permutation ( I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = Pred { } ,

Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } ) ;
(1) (ranges TS)
template < ForwardRange R1, ForwardRange R2, class Pred = ranges:: equal_to <> ,

class Proj1 = ranges:: identity , class Proj2 = ranges:: identity >
requires IndirectlyComparable < ranges:: iterator_t < R1 > , ranges:: iterator_t < R2 > ,
Pred, Proj1, Proj2 >
bool is_permutation ( R1 && r1, R2 && r2, Pred pred = Pred { } ,

Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } ) ;
(2) (ranges TS)
template < ForwardIterator I1, Sentinel < I1 > S1, class I2,

class Pred = ranges:: equal_to <> ,
class Proj1 = ranges:: identity , class Proj2 = ranges:: identity >
requires ForwardIterator < std:: decay_t < I2 >> && ! Range < I2 > &&
IndirectlyComparable < I1, std:: decay_t < I2 > , Pred, Proj1, Proj2 >
bool is_permutation ( I1 first1, S1 last1, I2 && first2_, Pred pred = Pred { } ,

Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } ) ;
(3) (ranges TS)
(非推奨)
template < ForwardRange R1, class I2, class Pred = ranges:: equal_to <> ,

class Proj1 = ranges:: identity , class Proj2 = ranges:: identity >
requires ForwardIterator < std:: decay_t < I2 >> && ! Range < I2 > &&
IndirectlyComparable < ranges:: iterator_t < R1 > , std:: decay_t < I2 > , Pred, Proj1, Proj2 >
bool is_permutation ( R1 && r1, I2 && first2_, Pred pred = Pred { } ,

Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } ) ;
(4) (ranges TS)
(非推奨)
1) 範囲 [ first1 , last1 ) の要素の順列が範囲 [ first2 , last2 ) と等しくなるものが存在する場合は true を返し、それ以外の場合は false を返す。
2) (1) と同様だが、 r1 を第一ソース範囲として、 r2 を第二ソース範囲として使用する。すなわち ranges:: begin ( r1 ) first1 として、 ranges:: end ( r1 ) last1 として、 ranges:: begin ( r2 ) first2 として、 ranges:: end ( r2 ) last2 として使用する場合と同等である。
3) (1) と同様だが、 first2 は以下のように定義される: std:: decay_t < I2 > first2 = std:: forward < I2 > ( first2_ ) ; また last2 first2 + ( last1 - first1 ) である。
4) (3) と同様だが、 r1 を最初のソース範囲として使用する。 ranges:: begin ( r1 ) first1 として、 ranges:: end ( r1 ) last1 として使用するかのように動作する。

2つの範囲は、同じ数の要素を持ち、範囲 [ first1 , last1 ) 内のすべてのイテレータ i について、 ranges:: invoke ( pred, ranges:: invoke ( proj1, * i ) , ranges:: invoke ( proj2, * ( first2 + ( i - first1 ) ) ) ) true である場合に等しいと見なされます。

上記に示された宣言にかかわらず、アルゴリズム宣言の実際のテンプレートパラメータの数と順序は未規定です。したがって、アルゴリズムを呼び出す際に明示的なテンプレート引数を使用する場合、プログラムはおそらく移植性がありません。

目次

パラメータ

first1, last1 - 要素の最初の範囲
r1 - 要素の最初の範囲
first2, last2 - 要素の2番目の範囲
r2 - 要素の2番目の範囲
first2_ - 要素の2番目の範囲の開始位置
pred - 投影された要素に適用する述語
proj1 - 最初の範囲の要素に適用する投影
proj2 - 2番目の範囲の要素に適用する投影

戻り値

true 範囲 [ first1 , last1 ) が範囲 [ first2 , last2 ) の順列である場合。

計算量

最大で O(N 2 ) 回の述語と各射影の適用、またはシーケンスが既に等しい場合は正確に N 回、ここで N = last1 - first1

しかし、 SizedSentinel < S1, I1 > && SizedSentinel < S2, I2 > が満たされ、かつ last1 - first1 ! = last2 - first2 の場合、述語と射影の適用は行われません。

関連項目

あるシーケンスが別のシーケンスの順列であるかどうかを判定する
(関数テンプレート)
要素の範囲の辞書順による次の大きな順列を生成する
(関数テンプレート)
要素の範囲の辞書順による次の小さな順列を生成する
(関数テンプレート)