std::reverse_copy
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, class OutputIt > OutputIt reverse_copy( BidirIt first, BidirIt last, OutputIt d_first ); | ||
Copia gli elementi della
[first, last)
gamma, per un altro inizio montuoso a d_first
in modo tale che gli elementi della nuova gamma sono in.. ordine inverso. Original:
Copies the elements from the range
[first, last)
, to another range beginning at d_first
in such a way, that the elements in the new range are in reverse order. 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 | - | dell'intervallo di elementi da copiare Original: the range of elements to copy The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
d_first | - | l'inizio del campo di destinazione Original: the beginning of the destination range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Type requirements | ||
-BidirIt must meet the requirements of BidirectionalIterator . | ||
-OutputIt must meet the requirements of OutputIterator . |
[modifica]Valore di ritorno
uscita iteratore all'elemento passato l'ultimo elemento copiato.
Original:
Output iterator to the element past the last element copied.
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, class OutputIt> OutputIt reverse_copy(BidirIt first, BidirIt last, OutputIt d_first){while(first != last){*(d_first++)=*(--last);}return d_first;} |
[modifica]Esempio
#include <vector>#include <iostream>#include <algorithm> int main(){std::vector<int> v({1,2,3});std::for_each(std::begin(v), std::end(v), [&](int value){std::cout<< value <<" ";});std::cout<<std::endl; std::vector<int> destiny(3); std::reverse_copy(std::begin(v), std::end(v), std::begin(destiny));std::for_each(std::begin(destiny), std::end(destiny), [&](int value){std::cout<< value <<" ";});std::cout<<std::endl;}
Output:
1 2 3 3 2 1
[modifica]Complessità
lineare la distanza tra
first
e last
Original:
linear in the distance between
first
and 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.
[modifica]Vedi anche
inverte gli elementi di ordine in un intervallo Original: reverses the order elements in a range 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) |