Espaces de noms
Variantes
Affichages
Actions

std::iota

De cppreference.com
< cpp‎ | algorithm

 
 
Bibliothèque d'algorithmes
Fonctions
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Non-modification de la séquence des opérations
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.
Modification de la séquence des opérations
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.
Des opérations de partitionnement
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.
Opérations de tri (sur les gammes triés)
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.
is_sorted (C++11)
is_sorted_until (C++11)
sort
Opérations binaires de recherche (sur les gammes triés)
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.
Définir les opérations (sur les gammes triés)
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.
Opérations Heap
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 de fonctionnement
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.
Opérations numériques
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.
iota (C++11)
accumulate
inner_product
Bibliothèque C
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.
 
Defined in header <numeric>
template< class ForwardIterator, class T >
void iota( ForwardIterator first, ForwardIterator last, T value );
(depuis C++11)
Remplit le [first, last) gamme avec des valeurs qui augmentent successivement, en commençant par value et répétitive évaluation ++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.
Opération équivalente:
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;
...

Sommaire

[modifier] Paramètres

first, last -
la gamme des éléments de somme
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 -
valeur initiale pour le stockage, l'expression + + valeur doit être bien formé
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.

[modifier] Retourne la valeur

(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Complexité

Exactement last - first incréments et les affectations .
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.

[modifier] Mise en œuvre possible

template<class ForwardIterator, class T>
void iota(ForwardIterator first, ForwardIterator last, T value)
{
    while(first != last) {
        *first++ = value;
        ++value;
    }
}

[modifier] Exemple

L'exemple suivant applique std::random_shuffle à un vecteur d'itérateurs à un std::list depuis std::random_shuffle ne peut pas être appliqué à un std::list directement. std::iota est utilisée pour créer le vecteur .
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';
}

Résultat :

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

[modifier] Voir aussi

attribue un ensemble d'éléments d'une certaine valeur
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.

(fonction générique) [edit]
enregistre le résultat d'une fonction dans une plage
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.

(fonction générique) [edit]