hash_map::emplace_hint

备注

此 API 已过时。替代为 unordered_map 类

插入元素构造就地到 hash_map,与位置提示。

template<class ValTy>
    iterator emplace_hint(
        const_iterator _Where,
        ValTy&& _Val
);

参数

参数

说明

_Val

用于移动的值构造要插入的元素到 hash_map 类,除非 hash_map 已经包含该元素 (即,一般,键相同顺序排列) 的元素。

_Where

有关起始位置的提示搜索正确位置插入。

返回值

hash_multimap::emplace 成员函数返回指向新位置的元素插入 hash_map的迭代器,或者具有等效的顺序现有元素的位置。

备注

hash_map::value_type 元素是一对,因此,元素的值将与组件等于第一个值和第二个关键组件的一种有序的 to-string 等于元素的数据值。

如果插入点位紧跟 _Where,则插入在、的常量时发生,而不是对数时间。

从 Visual C++ .NET 2003 开始,<hash_map><hash_set> 和头文件的成员不再处于 std 命名空间,而是,将 stdext 命名空间。 有关更多信息,请参见 stdext 命名空间

示例

// hash_map_emplace_hint.cpp
// compile with: /EHsc
#include<hash_map>
#include<iostream>
#include <string>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_map<int, string> hm1;
    typedef pair<int, string> is1(1, "a");

    hm1.emplace(hm1.begin(), move(is1));
    cout << "After the emplace, hm1 contains:" << endl
      << " " << hm1.begin()->first
      << " => " << hm1.begin()->second
      << endl;
}
  

要求

标头: <hash_map>

**命名空间:**stdext

请参见

参考

hash_map 类

标准模板库