Espaces de noms
Variantes
Affichages
Actions

std::list::remove, std::list::remove_if

De cppreference.com
< cpp‎ | container‎ | list

 
 
 
std::list
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::list
list::~list
list::operator=
list::assign
list::get_allocator
Elément d'accès
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::front
list::back
Les itérateurs
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::begin
list::cbegin

(C++11)
list::end
list::cend

(C++11)
list::rbegin
list::crbegin

(C++11)
list::rend
list::crend

(C++11)
Capacité
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::empty
list::size
list::max_size
Modificateurs
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::clear
list::insert
list::emplace (C++11)
list::erase
list::push_front
list::emplace_front (C++11)
list::pop_front
list::push_back
list::emplace_back (C++11)
list::pop_back
list::resize
list::swap
Opérations
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::merge
list::splice
list::remove
list::remove_if
list::reverse
list::unique
list::sort
 
void remove( const T& value );
template< class UnaryPredicate >
void remove_if( UnaryPredicate p );
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.


Sommaire

[modifier] Paramètres

value -
valeur des éléments à supprimer
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
si l'élément doit être supprimé
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:

 bool pred(const Type &a);

The signature does not need to have const &, but the function must not modify the objects passed to it.
The type Type must be such that an object of type list<T,Allocator>::const_iterator can be dereferenced and then implicitly converted to Type. ​

[modifier] 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.

[modifier] 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.

[modifier] 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 :

2 3 10 -1

[modifier] 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.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]