std::unordered_map::insert
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
std::pair<iterator,bool> insert( const value_type& value ); |
(1) | (C++11 起) |
template <class P> std::pair<iterator,bool> insert( P&& value ); |
(2) | (C++11 起) |
iterator insert( const_iterator hint, const value_type& value ); |
(3) | (C++11 起) |
template <class P> iterator insert( const_iterator hint, P&& value ); |
(4) | (C++11 起) |
template< class InputIt > void insert( InputIt first, InputIt last ); |
(5) | (C++11 起) |
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
, using hint
as a non-binding suggestion to where the search should start.
[first, last)
.[first, last)
.ilist
.ilist
.If rehashing occurs due to the insertion, all iterators are invalidated. Otherwise iterators are not affected. References are not invalidated. Rehashing occurs only if the new number of elements is higher than max_load_factor()*bucket_count().
目录 |
[编辑] 参数
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-4) Average case: O(1)
, worst case O(size())
5-6) Average case: O(N)
, where N is the number of elements to insert. Worse case: O(N*size()+N)
[编辑] 另请参阅
就地构造元素 (公共成员函数) | |
构建了一丝元素的地方使用 原文: constructs elements in-place using a hint (公共成员函数) |