std::forward_list::remove, std::forward_list::remove_if
提供:cppreference.com
< cpp | container | forward list
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| void remove( const T& value ); |
(C + + 11以来) | |
| template< class UnaryPredicate > void remove_if( UnaryPredicate p ); |
(C + + 11以来) | |
特定の条件を満たすすべての要素を削除します。最初のバージョンは
valueと等しいすべての要素を削除し、2番目のバージョンは、すべての要素を除去するための述語p戻りtrue. Original:
Removes all elements satisfying specific criteria. The first version removes all elements that are equal to
value, the second version removes all elements for which predicate p returns true. 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.
目次 |
[編集] パラメータ
| value | - | 削除する要素の値
Original: value of the elements to remove 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: if the element should be removed 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:
The signature does not need to have const &, but the function must not modify the objects passed to it. | |||||||||
[編集] 値を返します
(なし)
Original:
(none)
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.
[編集] 複雑
容器の大きさに比例
Original:
linear in the size of the container
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.
[編集] 例
#include <forward_list> #include <iostream> int main() { std::forward_list<int> l = { 1,100,2,3,10,1,11,-1,12 }; l.remove(1); // remove both elements equal to 1 l.remove_if([](int n){ return n > 10; }); // remove all elements greater than 10 for (int n : l) { std::cout << n << ' '; } std::cout << '\n'; }
Output:
2 3 10 -1
[編集] も参照してください
| 特定の条件を満たす要素を削除します 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. (関数テンプレート) | |