Namensräume
Varianten
Aktionen

std::iota

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 <numeric>
template< class ForwardIterator, class T >
void iota( ForwardIterator first, ForwardIterator last, T value );
(seit C++11)
Füllt den Bereich [first, last) mit sequentiell steigenden Werten, beginnend mit value und wiederholt Auswertung ++value .
Original:
Fills the range [first, last) with sequentially increasing values, starting with value and repetitively evaluating ++value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Equivalent Betrieb:
Original:
Equivalent operation:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
*(d_first)   = value;
*(d_first+1) = ++value;
*(d_first+2) = ++value;
*(d_first+3) = ++value;
...

Inhaltsverzeichnis

[Bearbeiten] Parameter

first, last -
das Spektrum der Elemente Summe
Original:
the range of elements to sum
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
value -
Anfangswert zu speichern, der Ausdruck + + Wert muss wohlgeformt sein
Original:
initial value to store, the expression ++value must be well-formed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Rückgabewert

(None)
Original:
(none)
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 Schritten und Aufgaben .
Original:
Exactly last - first increments and 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 ForwardIterator, class T>
void iota(ForwardIterator first, ForwardIterator last, T value)
{
    while(first != last) {
        *first++ = value;
        ++value;
    }
}

[Bearbeiten] Beispiel

Das folgende Beispiel gilt std::random_shuffle auf einen Vektor von Iteratoren zu einem std::list seit std::random_shuffle nicht zu einer std::list direkt angewendet werden. std::iota wird verwendet, um den Vektor zu schaffen .
Original:
The following example applies std::random_shuffle to a vector of iterators to a std::list since std::random_shuffle cannot be applied to an std::list directly. std::iota is used to create the vector.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <numeric>
#include <algorithm>
#include <list>
#include <vector>
#include <iostream>
 
int main()
{
    std::list<int> l(10);
    std::iota(l.begin(), l.end(), -4);
 
    std::vector<std::list<int>::iterator> v(l.size());
    std::iota(v.begin(), v.end(), l.begin());
 
    std::random_shuffle(v.begin(), v.end());
 
    std::cout << "Contents of the list: ";
    for(auto n: l) {
        std::cout << n << ' ';
    }
    std::cout << '\n';
 
    std::cout << "Contents of the list, shuffled: ";
    for(auto i: v) {
        std::cout << *i << ' ';
    }
    std::cout << '\n';
}

Output:

Contents of the list: -4 -3 -2 -1 0 1 2 3 4 5
Contents of the list, shuffled: 0 -1 3 4 -4 1 -2 -3 2 5

[Bearbeiten] Siehe auch

weist eine Reihe von Elementen ein bestimmter Wert
Original:
assigns a range of elements a certain value
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]
speichert das Ergebnis einer Funktion in einem Bereich
Original:
saves the result of a function 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.

(Funktions-Template) [edit]