#include "stdafx.h"
#include <unordered_map>
#include <iostream>
using namespace std;
typedef tr1::unordered_map<int, int>MyMap ;
int _tmain(int argc, _TCHAR* argv[])
{
MyMap PolicyMap;
PolicyMap.insert(Myap::value_type(0, 10));
PolicyMap.insert(Myap::value_type(1, 20));
PolicyMap.insert(Myap::value_type(2, 30));
for (Myap::const_iterator i = PolicyMap.begin(); i != PolicyMap.end() ; i++)
{
cout << " [" << i->first << ", " << i->second << "]" << endl;
}
return 0;
}
为什么上面代码的输出是 [0, 10], [2, 30], [1, 20] 。它应该是 [2, 30], [1, 20], [0, 10]。只有当我从零开始输入键值时才会发生这种情况,请帮忙