std::vector::insert
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
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); |
(4) | (至 C++11) (C++11 起) |
iterator insert( const_iterator pos, std::initializer_list<T> ilist ); |
(5) | (C++11 起) |
value
所指向的元素之前pos
value
before the element pointed to by pos
count
的元素之前插入value
副本指出pos
count
copies of the value
before the element pointed to by pos
[first, last)
的元素之前插入元素指出pos
[first, last)
before the element pointed to by pos
ilist
.ilist
.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 |
value | - | 元素的值插入
|
first, last | - | 的范围内的元素插入,不能插入被称为容器的迭代器
原文: the range of elements to insert, can't be iterators into container for which insert is called |
ilist | - | 初始化列表中插入的值
原文: initializer list to insert the values from |
类型要求 | ||
-InputIt 必须满足 InputIterator 的要求。
|
[编辑] 返回值
1-2)value
value
pos
如果count==0.pos
if count==0.pos
如果first==last.pos
if first==last.pos
如果ilist
是空的.pos
if ilist
is empty.[编辑] 复杂性
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) |
就地构造元素 (公共成员函数) |
将元素添加到末端 (公共成员函数) |