![]() |
---|
此 API 已过时。另一种方法是 unordered_set Class。 |
插入构造的元素就地到 hash_set 中。
template<class ValTy>
iterator emplace(
const_iterator _Where,
ValTy&& _Val
);
参数
Parameter |
描述 |
_Val |
要插入的元素的值设置为 hash_set Class,除非 hash_set,通常,已包含该元素或键相同地排序的元素。 |
_Where |
起始位置搜索正确位置插入。(插入在能够的常量时发生,而不是对数时,因此,如果插入点紧跟在 _Where。) |
返回值
hash_set::emplace 成员函数返回指向位置新元素插入 hash_set的迭代器,或在的位置等效排序的现有元素。
备注
如果插入点紧跟在 _Where,在将能够的常量时发生,而不是对数时间。
在 Visual C++ .NET 2003 中,<hash_map> 和 <hash_set> 标头文件的成员中不再标准,命名空间,而是将 stdext 命名空间。有关更多信息,请参见 stdext 命名空间。
示例
// hash_set_emplace_hint.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
#include <string>
int main( )
{
using namespace std;
using namespace stdext;
hash_set<string> hs3;
string str1("a");
hs3.insert(hs3.begin(), move(str1));
cout << "After the emplace insertion, hs3 contains "
<< *hs3.begin() << "." << endl;
}
要求
标头: <hash_set>
命名空间: stdext