The Wayback Machine - https://web.archive.org/web/20171224235458/http://ja.cppreference.com:80/w/cpp/algorithm/fill
名前空間
変種
操作

std::fill

提供: cppreference.com
< cpp‎ | algorithm

 
 
アルゴリズムライブラリ
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を非改変
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.
シーケンス動作を変更する
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.
操作を仕切る
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.
(ソートされた範囲で)ソート操作
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.
バイナリ検索操作(ソート範囲で)
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.
(ソートされた範囲で)操作を設定します
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.
ヒープ操作
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.
最小値/最大値操作
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.
数値演算
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ライブラリ
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 <algorithm>
template<class ForwardIt, class T >
void fill( ForwardIt first, ForwardIt last, const T& value );
レンジvalue内の要素に与え[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.

目次

[編集]パラメータ

first, last -
変更する要素の範囲
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 -
値が割り当てられる
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.
型の要件
-
ForwardItForwardIterator

の要求を満足しなければなりません。

[編集]値を返します

(なし)

[編集]複雑性

まさにlast - first割り当て.
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.

[編集]可能な実装

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

[編集]

次のコードは、-1までの整数のベクトルのすべての要素を設定するfill()使用しています
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";}

出力:

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

[編集]参照

要素の数に値を代入します
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.

(関数テンプレート)[edit]
範囲内の関数の結果を保存します
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.

(関数テンプレート)[edit]
ある範囲の要素に関数が適用されます
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.

(関数テンプレート)[edit]
close