共用方式為


hash_map::emplace_hint

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_map Class

插入建構的項目就地到 hash_map,具有位置提示。

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

參數

參數

描述

_Val

用於提供設計階段移動建構要插入中的項目 hash_maphash_map Class ,除非已經包含該項目 (或,一般而言,索引鍵相等的已排序的項目)。

_Where

如需這個位置開始的提示搜尋正確問題的外掛程式。

傳回值

指向新位置的項目插入 hash_map的 hash_multimap::emplace 成員函式傳回 Iterator,或者在位置與相等排序的現有項目。

備註

項目的 hash_map::value_type 是一組,因此元素,的值會與第一個元件相等於這個機碼值和第二個元件的已排序配對相等於這個項目之資料值。

如果插入點後面緊接著 _Where,插入在被轉換舊的常數時間可能發生,而不是對的時間。

從 Visual C++ .NET 開始 Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 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 Class

標準樣板程式庫