std::vector::insert

来自cppreference.com
< cpp‎ | container‎ | vector


 
 
 
std::vector
成员函数
原文:
Member functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
vector::vector
vector::~vector
vector::operator=
vector::assign
vector::get_allocator
元素的访问
原文:
Element access
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
vector::at
vector::operator[]
vector::front
vector::back
vector::data(C++11)
迭代器
原文:
Iterators
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
vector::begin
vector::cbegin

(C++11)
vector::end
vector::cend

(C++11)
vector::rbegin
vector::crbegin

(C++11)
vector::rend
vector::crend

(C++11)
容量
原文:
Capacity
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
vector::empty
vector::size
vector::max_size
vector::reserve
vector::capacity
vector::shrink_to_fit(C++11)
修饰符
原文:
Modifiers
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
vector::clear
vector::insert
vector::emplace(C++11)
vector::erase
vector::push_back
vector::emplace_back(C++11)
vector::pop_back
vector::resize
vector::swap
 
iterator insert( iterator pos, const T& value );
iterator insert( const_iterator pos, const T& value );
(1) (至 C++11)
(C++11 起)
iterator insert( const_iterator pos, T&& value );
(2) (C++11 起)
void insert( iterator pos, size_type count, const T& value );
iterator insert( const_iterator pos, size_type count, const T& value );
(3) (至 C++11)
(C++11 起)
template< class InputIt >

void insert( iterator pos, InputIt first, InputIt last);
template< class InputIt >

iterator insert( const_iterator pos, InputIt first, InputIt last );
(4) (至 C++11)

(C++11 起)
iterator insert( const_iterator pos, std::initializer_list<T> ilist );
(5) (C++11 起)
在容器中的指定位置插入元素.
原文:
Inserts elements to specified position in the container.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
1-2)
插入value所指向的元素之前pos
原文:
inserts value before the element pointed to by pos
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
3)
count的元素之前插入value副本指出pos
原文:
inserts count copies of the value before the element pointed to by pos
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
4)
范围[first, last)的元素之前插入元素指出pos
原文:
inserts elements from range [first, last) before the element pointed to by pos
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
5)
从初始化列表中插入元素ilist.
原文:
inserts elements from initializer list ilist.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

Causes reallocation if the new size() is greater than the old capacity().If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references after the added element are invalidated.

目录

[编辑] 参数

pos -
元素之前的内容将被插入
原文:
element before which the content will be inserted
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
value -
元素的值插入
原文:
element value to insert
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
first, last -
的范围内的元素插入,不能插入被称为容器的迭代器
原文:
the range of elements to insert, can't be iterators into container for which insert is called
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
ilist -
初始化列表中插入的值
原文:
initializer list to insert the values from
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类型要求
-
InputIt 必须满足 InputIterator 的要求。

[编辑] 返回值

1-2)
迭代器,指向插入的value
原文:
iterator pointing to the inserted value
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
3)
迭代器,指向第一个元素的插入,或pos如果count==0.
原文:
iterator pointing to the first element inserted, or pos if count==0.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
4)
迭代器,指向第一个元素的插入,或pos如果first==last.
原文:
iterator pointing to the first element inserted, or pos if first==last.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
5)
迭代器,指向第一个元素的插入,或pos如果ilist是空的.
原文:
iterator pointing to the first element inserted, or pos if ilist is empty.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 复杂性

1-2) Constant plus linear in the distance between pos and end of the container.

3) Linear in count plus linear in the distance between pos and end of the container.

4) Linear in std::distance(first, last) plus linear in the distance between pos and end of the container.

5) Linear in ilist.size() plus linear in the distance between pos and end of the container.

[编辑] 另请参阅

(C++11)
就地构造元素
(公共成员函数) [edit]
将元素添加到末端
(公共成员函数) [edit]