Espaços nominais
Variantes
Acções

std::fill

Da cppreference.com
< cpp‎ | algorithm

 
 
Biblioteca algoritmo
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não modificar operações de seqüência
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.
Modificando operações de seqüência
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.
Particionamento operações
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.
Operações de classificação (em intervalos ordenados)
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.
Binários operações de busca (em intervalos ordenados)
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.
Definir operações (em intervalos ordenados)
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.
Operações de pilha
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.
Mínimo / máximo de operações
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.
Operações numéricas
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 biblioteca
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.
 
Definido no cabeçalho <algorithm>
template<class ForwardIt, class T >
void fill( ForwardIt first, ForwardIt last, const T& value );
Atribui o value dada aos elementos da gama [first, last).
Original:
Assigns the given value to the elements 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.

Índice

[editar]Parâmetros

first, last -
a gama de elementos para modificar
Original:
the range of elements to modify
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
value -
o valor a ser atribuído
Original:
the value to be assigned
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Type requirements
-
ForwardIt must meet the requirements of ForwardIterator.

[editar]Valor de retorno

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

[editar]Complexidade

Exatamente last - first atribuições.
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.

[editar]Possível implementação

template<class ForwardIt, class T >void fill(ForwardIt first, ForwardIt last, const T& value){for(; first != last;++first){*first = value;}}

[editar]Exemplo

O código a seguir usa fill() para definir todos os elementos de um vetor de inteiros para -1:
Original:
The following code uses fill() to set all of the elements of a vector of integers to -1:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <algorithm>#include <vector>#include <iostream>   int main(){int data[]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}std::vector<int> v1(data, data+10);   std::fill(v1.begin(), v1.end(), -1);   for(vector<int>::iterator it = v1.begin(); it != v1.end();++it){std::cout<<*it <<" ";}std::cout<<"\n";}

Saída:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1

[editar]Veja também

atribui um valor a um certo número de elementos
Original:
assigns a value to a number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de função)[edit]
guarda o resultado de uma função em um intervalo
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.

(modelo de função)[edit]
aplica-se uma função de uma série de elementos
Original:
applies a function to a range of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de função)[edit]
close