std::list::remove, std::list::remove_if - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
|
|
||
|
|
||
Rimuove tutti gli elementi che soddisfano criteri specifici. La prima versione rimuove tutti gli elementi che sono uguali a value, la seconda versione rimuove tutti gli elementi per i quali predicato p ritorna 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.
Parametri
| value | - | valore degli elementi da rimuovere Original: value of the elements to remove The text has been machine-translated via Google Translate. |
| p | - | unary predicate which returns true se l'elemento deve essere rimosso Original: if the element should be removed The text has been machine-translated via Google Translate. The signature of the predicate function should be equivalent to the following:
The signature does not need to have |
Valore di ritorno
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Complessità
lineare nella dimensione del contenitore
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.
Esempio
#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'; }
Output:
Vedi anche
rimuove gli elementi che soddisfano criteri specifici Original: removes elements satisfying specific criteria The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |