Espaços nominais
Variantes
Acções

std::copy_backward

Da cppreference.com
< cpp‎ | algorithm

 
 
Biblioteca algoritmo
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não modificar operações de seqüência
Original:
Non-modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modificando operações de seqüência
Original:
Modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Particionamento operações
Original:
Partitioning operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operações de classificação (em intervalos ordenados)
Original:
Sorting operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Binários operações de busca (em intervalos ordenados)
Original:
Binary search operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definir operações (em intervalos ordenados)
Original:
Set operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operações de pilha
Original:
Heap operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Mínimo / máximo de operações
Original:
Minimum/maximum operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operações numéricas
Original:
Numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
C biblioteca
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <algorithm>
template< class BidirIt1, class BidirIt2 >
BidirIt2 copy_backward( BidirIt1 first, BidirIt1 last, BidirIt2 d_last );
Copia os elementos da gama, definida por [first, last), para outro intervalo terminando no d_last. Os elementos são copiados em ordem inversa (o último elemento é copiado primeiro), mas a sua ordem relativa é preservada.
Original:
Copies the elements from the range, defined by [first, last), to another range ending at d_last. The elements are copied in reverse order (the last element is copied first), but their relative order is preserved.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Parâmetros

first, last -
a gama de elementos de copiar
Original:
the range of the 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_last -
final do intervalo de destino. Se d_last está dentro [first, last), std::copy deve ser utilizado em vez de std::copy_backward .
Original:
end of the destination range. If d_last is within [first, last), std::copy must be used instead of std::copy_backward.
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.

[editar] Valor de retorno

iterador para o último elemento copiado.
Original:
iterator to 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.

[editar] Complexidade

Exatamente last - first atribuições.
Original:
Exactly last - first assignments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Possível implementação

template< class BidirIt1, class BidirIt2 >
BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last)
{
    while (first != last) {
        *(--d_last) = *(--last);
    }
    return d_last;
}

[editar] Exemplo

#include <algorithm>
#include <iostream>
 
int main()
{
    std::vector<int> from_vector;
    for (int i = 0; i < 10; i++) {
        from_vector.push_back(i);
    }
 
    std::vector<int> to_vector(15);
 
    std::copy_backward(from_vector.begin(), from_vector.end(), to_vector.end());
 
    std::cout << "to_vector contains: ";
    for (unsigned int i = 0; i < to_vector.size(); i++) {
        std::cout << to_vector[i] << " ";
    }
 }

Saída:

to_vector contains: 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9

[editar] Veja também

Copia um intervalo de elementos para um novo local
Original:
copies a range of elements to a new location
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de função) [edit]