std::is_partitioned
提供: cppreference.com
                    
                                        
                    
                    
                                                            
                    |  | このページは、Google 翻訳を使って英語版から機械翻訳されました。 
 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 | 
| Defined in header <algorithm>
  | ||
| template< class InputIt, class UnaryPredicate > bool is_partitioned( InputIt first, InputIt last, UnaryPredicate p ); | (C++11およびそれ以降) | |
trueしないすべての要素の前に表示される述語を満たす範囲
[first, last)内のすべての要素があれば返しp。 true空の場合も[first, last)を返します。.Original:
Returns true if all elements in the range 
[first, last) that satisfy the predicate p appear before all elements that don't. Also returns true if [first, last) is empty.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| 目次 | 
[編集] パラメータ
| first, last | - |  チェックする要素の範囲 Original:  the range of elements to check The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | 
| p | - | unary predicate which returns true  範囲の先頭で発見されることが期待要素のため . Original:  for the elements expected to be found in the beginning of the range  The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. The signature of the predicate function should be equivalent to the following: bool pred(const Type &a); The signature does not need to have const &, but the function must not modify the objects passed to it. | 
| 型の要件 | ||
| - InputItはInputIteratorの要求を満足しなければなりません。 | ||
[編集] 値を返します
true範囲
[first, last)が空であるかpにパーティション化されている場合。 falseその他のとき.Original:
true if the range 
[first, last) is empty or is partitioned by p. false otherwise.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 複雑性
std::distance(first, last)の最もpアプリケーションで.Original:
At most 
std::distance(first, last) applications of p.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 可能な実装
| template< class InputIt, class UnaryPredicate > bool is_partitioned(InputIt first, InputIt last, UnaryPredicate p) { for (; first != last; ++first) if (!p(*first)) break; for (; first != last; ++first) if (p(*first)) return false; return true; } | 
[編集] 例
このコードを実行します
#include <algorithm> #include <array> #include <iostream> int main() { std::array<int, 9> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; auto is_even = [](int i){ return i % 2 == 0; }; std::cout.setf(std::ios_base::boolalpha); std::cout << std::is_partitioned(v.begin(), v.end(), is_even) << ' '; std::partition(v.begin(), v.end(), is_even); std::cout << std::is_partitioned(v.begin(), v.end(), is_even) << ' '; std::reverse(v.begin(), v.end()); std::cout << std::is_partitioned(v.begin(), v.end(), is_even); }
出力:
false true false
[編集] 参照
|  二つのグループに要素の範囲を分割します  Original:  divides a range of elements into two groups  The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
| (C++11) | locates the partition point of a partitioned range (関数テンプレート) | 


