Namensräume
Varianten
Aktionen

std::copy_backward

Aus cppreference.com
< cpp‎ | algorithm

 
 
Algorithm Bibliothek
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Nicht-modifizierende Sequenz Operationen
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.
Modifizierende Sequenz Operationen
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.
Partitionierungsoperationen
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.
Sortierung Operationen (auf sortierten Bereiche)
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.
Binary Suchaktionen (auf sortierten Bereiche)
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.
Set-Operationen (auf sortierten Bereiche)
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.
Heap-Operationen
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.
Minimum / Maximum Operationen
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.
Numerische Operationen
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-Bibliothek
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.
 
definiert in Header <algorithm>
template< class BidirIt1, class BidirIt2 >
BidirIt2 copy_backward( BidirIt1 first, BidirIt1 last, BidirIt2 d_last );
Kopiert die Elemente aus dem Bereich von [first, last) definiert, in einen anderen Bereich endet bei d_last. Die Elemente werden in umgekehrter Reihenfolge (das letzte Element wird zuerst kopiert) kopiert, aber ihre relative Reihenfolge beibehalten wird .
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.

Inhaltsverzeichnis

[Bearbeiten] Parameter

first, last -
der Bereich der Elemente zu kopieren
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 -
Ende des Zielbereichs. Wenn d_last in [first, last) ist, muss std::copy statt std::copy_backward verwendet werden .
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.

[Bearbeiten] Rückgabewert

Iterator auf das letzte Element kopiert .
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.

[Bearbeiten] Komplexität

Genau last - first Aufgaben .
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.

[Bearbeiten] Mögliche Implementierung

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

[Bearbeiten] Beispiel

#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] << " ";
    }
 }

Output:

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

[Bearbeiten] Siehe auch

Kopiert einen Bereich von Elementen, um eine neue Position
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.

(Funktions-Template) [edit]