Unlike member function list::erase, which erases elements by their position (iterator), this function (list::remove) removes elements by their value.
A similar function, list::remove_if, exists, which allows for a condition other than a plain value comparison to be performed on each element in order to determine the elements to be removed.
Notice that a global algorithm function, remove, exists with a similar behavior but operating between two iterators.
Parameters
- value
- Value of the elements to be removed.
T is the first class template parameter (the type of the elements stored in the list container).
Return value
noneExample
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Output:
mylist contains: 17 7 14 |
Complexity
Linear in list::size (comparisons).See also
| list::remove_if | Remove elements fulfilling condition (public member function template) |
| list::erase | Erase elements (public member function) |
| list::unique | Remove duplicate values (member function) |
| list::pop_back | Delete last element (public member function) |
| list::pop_front | Delete first element (public member function) |
