std::vector::assign
提供:cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| void assign( size_type count, const T& value ); |
(1) | |
| template< class InputIt > void assign( InputIt first, InputIt last ); |
(2) | |
コンテナの内容を置き換え.
1) 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.
You can help to correct and verify the translation. Click here for instructions.
値
2) countのvalueのコピーで内容を置き換えますOriginal:
replaces the contents with
count copies of value valueThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
レンジ
[first, last)のもののコピーで内容を置き換えます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.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
| count | - | コンテナの新しいサイズ
Original: the new size 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. |
| value | - | でコンテナの要素を初期化するための値
Original: the value to initialize elements of the container with 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 to copy the elements from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| Type requirements | ||
-InputIt must meet the requirements of InputIterator.
| ||
[編集] 複雑
1)countの線形Original:
linear in
countThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
firstlastとの間の距離の線形Original:
linear in distance between
first and lastThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
次のコードは、
assignにいくつかの文字を追加する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.
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:
a a a a a
[編集] も参照してください
vectorを構築します Original: constructs the vector The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |