std::set::insert
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
std::pair<iterator,bool> insert( const value_type& value ); |
(1) | |
std::pair<iterator, bool> insert( value_type&& value ); |
(2) | (C++11 起) |
iterator insert( iterator hint, const value_type& value ); iterator insert( const_iterator hint, const value_type& value ); |
(3) | (至 C++11) (C++11 起) |
iterator insert( const_iterator hint, value_type&& value ); |
(4) | (C++11 起) |
template< class InputIt > void insert( InputIt first, InputIt last ); |
(5) | |
void insert( std::initializer_list<value_type> ilist ); |
(6) | (C++11 起) |
Inserts element(s) to the container, if the container doesn't already contain an element with equivalent key.
1-2)value
。 3-4) inserts value
in the position as close as possible, just prior(C++11 起), to hint
.
[first, last)
.[first, last)
.ilist
.ilist
.No iterators or references are invalidated.
目录 |
[编辑] 参数
hint | - | 迭代器,用于插入内容,作为一个建议
原文: iterator, used as a suggestion as to where to insert the content |
value | - | 元素的值插入
|
first, last | - | 范围插入的元素
|
ilist | - | 初始化列表中插入的值
原文: initializer list to insert the values from |
类型要求 | ||
-InputIt 必须满足 InputIterator 的要求。
|
[编辑] 返回值
1-2) returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.
3-4) returns an iterator to the inserted element, or to the element that prevented the insertion.
5-6)[编辑] 复杂性
1-2) Logarithmic in the size of the container, O(log(size()))
.
3-4) Amortized constant if the insertion happens in the position just after(至 C++11)/before(C++11 起) the hint, logarithmic in the size of the container otherwise.
5-6) O(N*log(size() + N))
, where N is the number of elements to insert.
[编辑] 另请参阅
(C++11) |
就地构造元素 (公共成员函数) |
(C++11) |
构建了一丝元素的地方使用 原文: constructs elements in-place using a hint (公共成员函数) |