The Wayback Machine - https://web.archive.org/web/20171013013515/http://it.cppreference.com:80/w/cpp/algorithm/iota

std::iota

Da cppreference.com.
< cpp‎ | algorithm

 
 
Algoritmo libreria
Funzioni
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 modifica le operazioni di sequenza
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.
Modifica delle operazioni di sequenza
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.
Partizionamento operazioni
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.
Ordinamento delle operazioni (su intervalli ordinati)
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.
Binarie (le operazioni di ricerca sui campi ordinati)
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.
Impostare le operazioni (su intervalli ordinati)
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 operazioni
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.
Minimo / massimo le operazioni
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.
Operazioni numeriche
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.
Libreria 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 );
(dal C++11)
Riempie l'[first, last) gamma con valori crescenti in sequenza, a partire da value e ripetutamente la valutazione ++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.
Equivalente funzionamento:
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; ...

Indice

[modifica]Parametri

first, last -
l'intervallo di elementi di somma
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 -
valore iniziale al negozio, l'espressione valore + + deve essere ben formato
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.

[modifica]Valore di ritorno

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

[modifica]Complessità

Esattamente last - first incrementi e le assegnazioni.
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.

[modifica]Possibile implementazione

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

[modifica]Esempio

L'esempio seguente applica std::random_shuffle ad un vettore di iteratori ad un std::liststd::random_shuffle poiché non può essere applicata a un std::list direttamente. std::iota viene utilizzato per creare il vettore .
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

[modifica]Vedi anche

assegna un intervallo di elementi di un certo valore
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.

(funzione di modello)[edit]
salva il risultato di una funzione in un intervallo
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.

(funzione di modello)[edit]
close