std::list::remove, std::list::remove_if — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
|
|
||
|
|
||
Supprime tous les éléments répondant à des critères spécifiques. La première version supprime tous les éléments qui sont égaux à value, la deuxième version supprime tous les éléments pour lesquels prédicat retourne 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.
Paramètres
| value | - | valeur des éléments à supprimer Original: value of the elements to remove The text has been machine-translated via Google Translate. |
| p | - | prédicat unéaire qui retourne true si l'élément doit être supprimé Original: if the element should be removed The text has been machine-translated via Google Translate. L'expression |
Retourne la valeur
(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Complexité
linéaire à la taille du récipient
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.
Exemple
#include <list> #include <iostream> int main() { std::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'; }
Résultat :
Voir aussi
supprime des éléments répondant à des critères spécifiques Original: removes elements satisfying specific criteria The text has been machine-translated via Google Translate. (fonction générique) [edit] | |