std::list::remove, remove_if
From cppreference.com
void remove( const T& value ); |
||
template< class UnaryPredicate > void remove_if( UnaryPredicate p ); |
||
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.
Parameters
value | - | value of the elements to remove |
p | - | unary predicate which returns true if the element should be removed. 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. |
Return value
(none)
Complexity
Linear in the size of the container
Example
Run this code
Output:
2 3 10 -1
See also
removes elements satisfying specific criteria (function template) |