std::vector::assign - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
|
|
(1) | |
|
|
(2) | |
Sostituisce il contenuto del contenitore.
Original:
Replaces the contents of the container.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
sostituisce il contenuto con le copie di count value valore
Original:
replaces the contents with count copies of value value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
sostituisce il contenuto con le copie di quelli del [first, last) gamma
Original:
replaces the contents with copies of those in the range [first, last)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parametri
| count | - | la nuova dimensione del contenitore Original: the new size of the container The text has been machine-translated via Google Translate. |
| value | - | il valore per inizializzare elementi del contenitore Original: the value to initialize elements of the container with The text has been machine-translated via Google Translate. |
| first, last | - | l'intervallo per copiare gli elementi da Original: the range to copy the elements from The text has been machine-translated via Google Translate. |
| Type requirements | ||
-InputIt must meet the requirements of InputIterator.
| ||
Complessità
1)
lineare in count
Original:
linear in count
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
lineare di distanza tra first e last
Original:
linear in distance between first and last
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esempio
Il codice seguente utilizza assign per aggiungere diversi personaggi a un std::vector<char>:
Original:
The following code uses assign to add several characters to a std::vector<char>:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <vector> #include <iostream> int main() { std::vector<char> characters; characters.assign(5, 'a'); for (char c : characters) { std::cout << c << '\n'; } return 0; }
Output: