std::vector
提供: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. |
Defined in header <vector>
|
||
template< class T, |
||
std::vector
動的なサイズの配列をカプセル化シーケンスコンテナです.Original:
std::vector
is a sequence container that encapsulates dynamic size arrays.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.
要素は、要素はだけでなくイテレータを介してアクセスするだけでなく、要素への定期的なポインタでオフセットを使用してできることを意味し、連続して格納されます。これは、ベクトルの要素へのポインタは配列の要素へのポインタを受け取る任意の関数に渡すことができることを意味します.
Original:
The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets on regular pointers to elements. This means that a pointer to an element of a vector may be passed to any function that expects a pointer to an element of an array.
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.
ベクトルのストレージが必要に応じて伸縮されて、自動的に処理されます。より多くのメモリは、将来の成長を処理するために割り当てられているため、ベクターは、通常、静的な配列よりも大きな領域を占めている。このようにベクトルは、要素が挿入されるたびに再割り当てする必要はありませんが、追加のメモリが枯渇している場合のみです。割り当てられたメモリの総量は
capacity()
機能を使用して照会できます。余分なメモリがshrink_to_fit()
への呼び出しを介してシステムに戻すことができます.Original:
The storage of the vector is handled automatically, being expanded and contracted as needed. Vectors usually occupy more space than static arrays, because more memory is allocated to handle future growth. This way a vector does not need to reallocate each time an element is inserted, but only when the additional memory is exhausted. The total amount of allocated memory can be queried using
capacity()
function. Extra memory can be returned to the system via a call to shrink_to_fit()
.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.
再配分は通常、パフォーマンスの面で高価な操作です。要素数があらかじめわかっている場合
reserve()
関数は再割り当てを排除するために使用することができます.Original:
Reallocations are usually costly operations in terms of performance.
reserve()
function can be used to eliminate reallocations if the number of elements is known beforehand.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.
ベクトル上の一般的な操作の複雑さ(効率)は以下の通りです:
Original:
The complexity (efficiency) of common operations on vectors is as follows:
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.
- ランダムアクセス - 定数O(1)Original:Random access - constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 最後に挿入または要素の除去 - 償却定数O(1)Original:Insertion or removal of elements at the end - amortized constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 要素の挿入または取り外し - ベクトルO(n)の端までの距離の線形Original:Insertion or removal of elements - linear in distance to the end of the vector O(n)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::vector
Container
の要件を満たし、AllocatorAwareContainer
、SequenceContainer
とReversibleContainer
.Original:
std::vector
meets the requirements of Container
, AllocatorAwareContainer
, SequenceContainer
and ReversibleContainer
.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.
[編集] スペシャ
標準ライブラリには、スペース効率のために最適化されている型
std::vector
用boolの専門性を提供しています.Original:
The standard library provides a specialization of
std::vector
for the type bool, which is optimized for space efficiency.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.
スペース効率に優れたダイナミックbitsetの Original: space-efficient dynamic bitset The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
[編集] メンバータイプ
メンバー·タイプ
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
T
|
allocator_type
|
Allocator
|
size_type
|
符号なし整数型(通常size_t)
Original: Unsigned integral type (usually size_t) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
difference_type
|
Signed integer type (usually ptrdiff_t) |
reference
|
Allocator::reference (C + + 11時まで)value_type& (C + + 11以来)
|
const_reference
|
Allocator::const_reference (C + + 11時まで)const value_type& (C + + 11以来)
|
pointer
|
Allocator::pointer (C + + 11時まで)std::allocator_traits<Allocator>::pointer (C + + 11以来) |
const_pointer
|
Allocator::const_pointer (C + + 11時まで) std::allocator_traits<Allocator>::const_pointer (C + + 11以来) |
iterator
|
RandomAccessIterator
|
const_iterator
|
一定のランダムアクセス反復子を返します
Original: Constant random access iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
reverse_iterator
|
std::reverse_iterator<iterator> |
const_reverse_iterator
|
std::reverse_iterator<const_iterator> |
[編集] メンバ関数
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. (パブリックメンバ関数) | |
destructs the vector (パブリックメンバ関数) | |
コンテナに値を割り当てます Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
コンテナに値を割り当てます Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
関連したアロケータを返す Original: returns the associated allocator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
Original: Element access The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
境界チェックと指定された要素にアクセスします Original: access specified element with bounds checking The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
指定された要素にアクセスします Original: access specified element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
最初の要素にアクセスします Original: access the first element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
access the last element (パブリックメンバ関数) | |
(C++11) |
基になる配列へのアクセスを指示する Original: direct access to the underlying array The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
Original: Iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
先頭を指すイテレータを返す Original: returns an iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
末尾を指すイテレータを返す Original: returns an iterator to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
先頭に逆反復子を返します Original: returns a reverse iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
最後に逆反復子を返します Original: returns a reverse iterator to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
Original: Capacity The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
容器が空であるかどうかをチェックします Original: checks whether the container is empty The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
要素数を返します Original: returns the 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. (パブリックメンバ関数) | |
要素の最大数を返します Original: returns the maximum possible 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. (パブリックメンバ関数) | |
埋蔵ストレージ Original: reserves storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
現在割り当てられているストレージに保持することができる要素の数を返します Original: returns the number of elements that can be held in currently allocated storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
(C++11) |
未使用のメモリを解放してメモリ使用量を減らすことができます Original: reduces memory usage by freeing unused memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
内容をクリアします Original: clears the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
インサート要素 Original: inserts elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
(C++11) |
constructs element in-place (パブリックメンバ関数) |
消去さ要素 Original: erases elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
最後に要素を追加します Original: adds elements to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
(C++11) |
終了時にその場で要素を構成します Original: constructs elements in-place at the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
最後の要素を削除します Original: removes the last element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
changes the number of elements stored (パブリックメンバ関数) | |
スワップ内容 Original: swaps the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
[編集] 非メンバ関数
辞書的にvector内の値を比較します Original: lexicographically compares the values in the vector The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
std::swapアルゴリズムを専門としています Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |