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 Class に挿入する要素 (または、より一般的には、キーが同じで並べる) 要素は。 |
_Where |
挿入の正しいポイントの検索を開始する場所に関するヒント。 |
戻り値
hash_multimap::emplace のメンバー関数は、新しい要素を挿入 hash_mapに、または場所で同じ大小関係を使用して既存の要素が出現位置を指す反復子を返します。
解説
要素の hash_map::value_type は、要素の値がキー値と等しい最初の構成要素および要素のデータ値と等しい2番目のコンポーネントとの順序付けられたペアになるように、ペアです。
挿入は対数の時間ではなく償却定数時間で挿入位置がの _Whereする場合は、発生することがあります。
Visual C++ .NET 2003以降では、<hash_map> と <hash_set> ヘッダー ファイルのメンバーはstdの名前空間に存在しなくなりましたが、ではなくstdextの名前空間に型。詳細については、「The stdext Namespace」を参照してください。
使用例
// 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