unordered_map
それで、私はSTLから新しく標準化されたもので遊んでいました。私が持っているコードはこのようなものです。 unordered_map を作成し、それを埋めて、出力するだけです:
unordered_map<int,string> m1;
m1[5]="lamb";
m1[2]="had";
m1[3]="a";
m1[1]="mary";
m1[4]="little";
m1[7]="fleece";
m1[6]="whose";
m1[10]="fleecey";
m1[8]="was";
m1[9]="all";
for(unordered_map<int,string>::const_iterator i = m1.begin(); i != m1.end(); ++i)
cout<<i->first<<" "<<i->second<<endl;
ただし、取得する出力は次のように並べられています。
1 mary
2 had
3 a
4 little
5 lamb
6 whose
7 fleece
8 was
9 all
10 fleecey
しかし、地図を注文してもらうために代価を払いたくありません! それが unordered_map を使用している理由です...ここで何が起こっているのですか?
追記:私はgcc version 4.3.4 20090804 (release) 1 (GCC)
このように使用してコンパイルしていますg++ -std=c++0X maptest.cpp