Espacios de nombres
Variantes
Acciones

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

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

 
 
 
std::list
Las funciones miembro
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.
Elemento acceso
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.
Los iteradores
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Capacidad
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modificadores
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operaciones
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::removelist::remove_if
 
void remove( const T& value );
template< class UnaryPredicate >
void remove_if( UnaryPredicate p );
Quita todos los elementos que cumplan criterios específicos. La primera versión elimina todos los elementos que son iguales a value, la segunda versión elimina todos los elementos para los que predicado p vuelve 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.


Contenido

[editar] Parámetros

value -
valor de los elementos a eliminar
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 - predicado unario que devuelve ​true
si el elemento debe ser eliminado
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.
.

La firma de la función predicado debe ser equivalente a:

 bool pred(const Type &a);

La forma no necesita tener const &, pero la función no debe modificar el objeto que ha sido pasado.
El tipo Type debe ser tal que un objeto del tipo list<T,Allocator>::const_iterator puede ser derreferenciado y entonces convertido implícitamente a Type. ​

[editar] Valor de retorno

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Complejidad

lineal en el tamaño del recipiente
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.

[editar] Ejemplo

#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';
}

Salida:

2 3 10 -1

[editar] Ver también

elimina elementos que cumplan criterios específicos
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.

(plantilla de función) [editar]