std::reverse
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. | 
| Defined in header <algorithm>
  | ||
| template< class BidirIt > void reverse( BidirIt first, BidirIt last ); | ||
Inverte l'ordine degli elementi nel 
[first, last) gamma.Original:
Reverses the order of the elements in the range 
[first, last).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| Indice | 
[modifica] Parametri
| first, last | - |  la gamma di elementi per invertire Original:  the range of elements to reverse The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | 
| Type requirements | ||
| - BidirItmust meet the requirements ofBidirectionalIterator. | ||
| -The type of dereferenced BidirItmust meet the requirements ofSwappable. | ||
[modifica] 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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Possibile implementazione
| template<class BidirIt> void reverse(BidirIt first, BidirIt last) { while ((first != last) && (first != --last)) { std::swap(*first++, *last); } } | 
[modifica] Esempio
#include <vector> #include <iostream> #include <algorithm> int main(int argc, char** argv) { std::vector<int> v({1,2,3}); std::reverse(std::begin(v), std::end(v)); std::cout << v[0] << v[1] << v[2] << '\n'; int a[] = {4, 5, 6, 7}; std::reverse(&a[0], &a[4]); std::cout << a[0] << a[1] << a[2] << a[3] << '\n'; }
Output:
321 7654
[modifica] Complessità
lineare la distanza tra 
first e lastOriginal:
linear in the distance between 
first and lastThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Vedi anche
|  crea una copia di un intervallo che è invertita  Original:  creates a copy of a range that is reversed  The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |


