アルゴリズムライブラリ
提供: cppreference.com
< cpp
アルゴリズムライブラリは要素の範囲に対して操作を行う様々な目的 (検索、ソート、計数、操作など) の関数を定義します。 範囲は [first, last)
として定義され、 last
は調査または変更する最後の要素の次の要素を参照することに注意してください。
実行ポリシーほとんどのアルゴリズムには実行ポリシーを受け取るオーバーロードがあります。 標準ライブラリのアルゴリズムは3つの実行ポリシー sequential, parallel, parallel+vector をサポートしており、対応する実行ポリシーの型とオブジェクトが提供されます。 ユーザは対応する型の実行ポリシーオブジェクト std::execution::seq, std::execution::par, std::execution::par_unseq のいずれかを指定して並列アルゴリズムを呼び出すことで、実行ポリシーを静的に選択できます。 標準ライブラリの実装は拡張として追加の実行ポリシーを定義している場合があります。 処理系定義型の実行ポリシーオブジェクトを指定して並列アルゴリズムを呼び出した場合のセマンティクスは処理系定義です。
| (C++17およびそれ以降) |
非変更シーケンス操作 | |
ヘッダ <algorithm> で定義 | |
(C++11) (C++11) (C++11) | 述語かどうかをチェックするには、すべてのtrue、範囲内の要素のいずれか、またはnoneです Original: checks if a predicate is true for all, any or none of the elements in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
ある範囲の要素に関数が適用されます Original: applies a function to a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++17) | applies a function object to the first n elements of a sequence (関数テンプレート) |
特定の条件を満たす要素の数を返します Original: returns the number of elements satisfying specific criteria The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
2の範囲が異なる最初の位置を見つけます Original: finds the first position where two ranges differ The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++11) | 特定の条件を満たす最初の要素を検索します Original: finds the first element satisfying specific criteria The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
一定の範囲内にある要素の最後のシーケンスを見つけることができます Original: finds the last sequence of elements in a certain range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
searches for any one of a set of elements (関数テンプレート) | |
互いに隣接する2つの同一の(またはいくつかの他の関係)のアイテムを見つけることができます Original: finds two identical (or some other relationship) items adjacent to each other The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
ある範囲の要素を検索します (関数テンプレート) | |
範囲内の要素の数は連続したコピーを検索します Original: searches for a number consecutive copies of an element in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
変更シーケンス操作 | |
ヘッダ <algorithm> で定義 | |
(C++11) | 新しい場所に要素の範囲をコピーします Original: copies a range of elements to a new location The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | 新しい場所にある要素の数をコピーします Original: copies a number of elements to a new location The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
コピー下位の順序で要素の範囲 Original: copies a range of elements in backwards order The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++11) | 新しい場所に要素の範囲を移動します Original: moves a range of elements to a new location The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | 下位の順序で新しい場所に要素の範囲を移動します Original: moves a range of elements to a new location in backwards order The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
要素の範囲を特定の値を割り当てます Original: assigns a range of elements a certain value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
要素の数に値を代入します Original: assigns a value to a number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
ある範囲の要素に関数が適用されます Original: applies a function to a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
範囲内の関数の結果を保存します Original: saves the result of a function in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
関数のNアプリケーションの結果を保存します Original: saves the result of N applications of a function The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
特定の条件を満たす要素を削除します Original: removes elements satisfying specific criteria The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
特定の条件を満たすものを省略要素の範囲をコピーします Original: copies a range of elements omitting those that satisfy specific criteria The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
別の値を使用して、特定の条件を満たすすべての値を置き換えます Original: replaces all values satisfying specific criteria with another value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
別の値を使用して、特定の条件を満たす要素を置き換えて、範囲をコピーします Original: copies a range, replacing elements satisfying specific criteria with another value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
2つのオブジェクトの値を交換します (関数テンプレート) | |
スワップの要素の2つの範囲を Original: swaps two ranges of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
スワップ二つのイテレータが指す要素 Original: swaps the elements pointed to by two iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
範囲内の秩序の要素を反転します Original: reverses the order elements in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
逆転された範囲のコピーを作成します Original: creates a copy of a range that is reversed The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
範囲内の要素の順序を回転させます Original: rotates the order of elements in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
コピーと要素の範囲を回転させます Original: copies and rotate a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++17以前) (C++11) | 範囲内の要素をランダムに並べ替えます (関数テンプレート) |
(C++17) | selects n random elements from a sequence (関数テンプレート) |
ある範囲内で連続して重複している要素を取り除きます (関数テンプレート) | |
全く連続した重複を含まない要素のいくつか範囲のコピーを作成します Original: creates a copy of some range of elements that contains no consecutive duplicates The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
分割操作 | |
ヘッダ <algorithm> で定義 | |
(C++11) | 範囲が指定された述語によって仕切られているかどうかを判断します Original: determines if the range is partitioned by the given predicate The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
二つのグループに要素の範囲を分割します 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) | copies a range dividing the elements into two groups (関数テンプレート) |
それらの相対的な順序を維持しながら、二つのグループに要素を分割します Original: divides elements into two groups while preserving their relative order 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 (関数テンプレート) |
ソート操作 | |
ヘッダ <algorithm> で定義 | |
(C++11) | 範囲は昇順にソートされているかどうかをチェックします Original: checks whether a range is sorted into ascending order The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | 最大のソート部分範囲を見つけることができます Original: finds the largest sorted subrange The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
昇順にソートする範囲 Original: sorts a range into ascending order The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
ソート範囲の最初のN要素 Original: sorts the first N elements of a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
コピーと部分的にソートする要素の範囲 Original: copies and partially sorts a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
ソートされた範囲の要素を等しい要素間の順序を維持しながら Original: sorts a range of elements while preserving order between equal elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
部分的にソートされ、指定された範囲は、それが与えられた要素によって仕切られていることを確認すること Original: partially sorts the given range making sure that it is partitioned by the given element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
バイナリサーチ操作 (ソート済み範囲に対する) | |
ヘッダ <algorithm> で定義 | |
最初の要素を指すイテレータを返す指定した値より小さくない Original: returns an iterator to the first element not less than the given value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
最初の要素を指すイテレータを返す特定の値より大きい Original: returns an iterator to the first element greater than a certain value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
要素が一定の範囲内に存在するかどうかを決定します Original: determines if an element exists in a certain range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
特定のキーと一致する要素の範囲を返します Original: returns range of elements matching a specific key The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
集合操作 (ソート済み範囲に対する) | |
ヘッダ <algorithm> で定義 | |
2つのソートされた範囲をマージします Original: merges two sorted ranges The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
その場で2つの順序の範囲をマージします Original: merges two ordered ranges in-place The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
1セットが他のサブセットである場合はtrueを返します Original: returns true if one set is a subset of another The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
2つの集合の差分を計算します (関数テンプレート) | |
2つの集合の積を計算します (関数テンプレート) | |
2セット間の対称差を計算します Original: computes the symmetric difference between two sets The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
2つの集合の和を計算します。 (関数テンプレート) | |
ヒープ操作 | |
ヘッダ <algorithm> で定義 | |
(C++11) | checks if the given range is a max heap (関数テンプレート) |
(C++11) | ヒープで最大の部分範囲を見つけることができます Original: finds the largest subrange that is heap The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
要素の範囲外のヒープを作成します Original: creates a heap out of a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
ヒープに要素を追加します Original: adds an element to a heap The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
ヒープから最大要素を削除します Original: removes the largest element from a heap The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
要素の並べ替えられた範囲にヒープを回す Original: turns a heap into a sorted range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
最小/最大演算 | |
ヘッダ <algorithm> で定義 | |
二つの要素のうちの大きい方を返します Original: returns the larger of two elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
範囲内の最大の要素を返します Original: returns the largest element in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
二つの要素のうち、小さい方を返します Original: returns the smaller of two elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
範囲内の最小の要素を返します Original: returns the smallest element in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++11) | 大きく2つの要素のうち小さい方を返します Original: returns the larger and the smaller of two elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++11) | 範囲内の最小と最大の要素を返します Original: returns the smallest and the largest element in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
(C++17) | clamps a value between a pair of boundary values (関数テンプレート) |
比較演算 | |
ヘッダ <algorithm> で定義 | |
要素の2セットが同じかどうかを判断します Original: determines if two sets of elements are the same The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
1範囲が別のより辞書式に小さい場合はtrueを返します Original: returns true if one range is lexicographically less than another The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++20) | compares two values using three-way comparison (関数テンプレート) |
(C++20) | compares two ranges using three-way comparison (関数テンプレート) |
順列操作 | |
ヘッダ <algorithm> で定義 | |
(C++11) | あるシーケンスが別のシーケンスの順列並び替えになっているか検査します (関数テンプレート) |
generates the next greater lexicographic permutation of a range of elements (関数テンプレート) | |
generates the next smaller lexicographic permutation of a range of elements (関数テンプレート) | |
数値演算 | |
ヘッダ <numeric> で定義 | |
(C++11) | 開始値の連続刻みで範囲を塗りつぶします Original: fills a range with successive increments of the starting value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
要素の範囲をまとめている Original: sums up a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
要素の2つの範囲の内積を計算します Original: computes the inner product of two ranges of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
範囲内の隣接する要素間の差を計算します Original: computes the differences between adjacent elements in a range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
要素の範囲の部分和を計算します Original: computes the partial sum of a range of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++17) | similar to std::accumulate, except out of order (関数テンプレート) |
(C++17) | similar to std::partial_sum, excludes the ith input element from the ith sum (関数テンプレート) |
(C++17) | similar to std::partial_sum, includes the ith input element in the ith sum (関数テンプレート) |
(C++17) | applies a functor, then reduces out of order (関数テンプレート) |
(C++17) | applies a functor, then calculates exclusive scan (関数テンプレート) |
(C++17) | applies a functor, then calculates inclusive scan (関数テンプレート) |
未初期化記憶域の操作 |
ヘッダ <memory> で定義 | |
メモリの初期化されていない領域へのオブジェクトの範囲をコピーします Original: copies a range of objects to an uninitialized area of memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++11) | メモリの初期化されていない領域へのオブジェクトの数をコピーします Original: copies a number of objects to an uninitialized area of memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
メモリの初期化されていない領域にオブジェクトをコピーします Original: copies an object to an uninitialized area of memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
メモリの初期化されていない領域にオブジェクトをコピーします Original: copies an object to an uninitialized area of memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
(C++17) | moves a range of objects to an uninitialized area of memory (関数テンプレート) |
(C++17) | moves a number of objects to an uninitialized area of memory (関数テンプレート) |
constructs objects by default-initialization in an uninitialized area of memory, defined by a range (関数テンプレート) | |
constructs objects by default-initialization in an uninitialized area of memory, defined by a start and a count (関数テンプレート) | |
constructs objects by value-initialization in an uninitialized area of memory, defined by a range (関数テンプレート) | |
constructs objects by value-initialization in an uninitialized area of memory, defined by a start and a count (関数テンプレート) | |
(C++17) | 指定されたアドレスにあるオブジェクトを破壊します (関数テンプレート) |
(C++17) | オブジェクトの範囲を破壊します (関数テンプレート) |
(C++17) | 範囲内のいくつかのオブジェクトを破壊します (関数テンプレート) |
C のライブラリ | |
ヘッダ <cstdlib> で定義 | |
ソートされていない型を持つ要素の範囲 Original: sorts a range of elements with unspecified type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
不特定の型の要素の配列を検索します Original: searches an array for an element of unspecified type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
[編集]関連項目
アルゴリズム の C言語リファレンス | |