>>704
いや、ordered_が付かないmapやsetは、順序で並び替えることも定義の一部になっていて、
範囲forで巡ると、挿入した順序ではなく、比較関数で比較した結果に基いてソートされた順序になる。
https://stackoverflow.com/questions/7648756/is-the-order-of-iterating-through-stdmap-known-and-guaranteed-by-the-standard
Yes, that's guaranteed. Moreover, *begin() gives you the smallest
C++
・std::map is a sorted associative container
https://stackoverflow.com/questions/11274978/are-c-stdmapstring-string-ordered
are STL maps ordered?
Yes, a std::map<K,V> is ordered based on the key, K, using std::less<K> to compare objects, by default.
So if I iterate over it, it will iterate with the first insert string first?
No. It will iterate based on the sorted order, not the order that you inserted elements. In the case of std::string, it sorts in lexicographic order (alphabetic order).
If you want to iterate based on the insertion order, you're better off using a sequence container, such as a std::vector or a std::list.
C++相談室 part162
■ このスレッドは過去ログ倉庫に格納されています
727デフォルトの名無しさん (オイコラミネオ MM7b-VZV0)
2022/12/14(水) 18:13:49.08ID:ekFaWlb/M■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【台湾有事】トランプ氏 電話会談で高市総理に発言抑制を要求か 米メディア報道… ★9 [BFU★]
- 【台湾有事】トランプ氏 電話会談で高市総理に発言抑制を要求か 米メディア報道… ★10 [BFU★]
- 【速報】 トランプ米大統領が高市首相に、台湾巡り助言したという報道は事実ではない 日本政府が否定 ★2 [お断り★]
- 経済誌元編集長「石破氏がコメ増産したからコメが余りまくってるどうしてくれるんだ」高市総理は悪夢の石破政権の尻ぬぐいしてる [バイト歴50年★]
- 英検、6級と7級新設へ 基礎レベルの学習に対応 [少考さん★]
- 【ひるおび】国分太一に「違和感」「筋違い」「独善的と思われても…」八代弁護士が厳しい言葉並べる [ぐれ★]
- 【悲報】エミンユルマズ「ネトウヨがWSJのジャーナリズムを問うには100年早い」 [733893279]
- 【実況】博衣こよりのえちえちholoXをおもてなされ🛸💜🥀🧪🍃
- 【悲報】高市内閣、トランプの顔に泥を塗る対応始める [256556981]
- 【ネトウヨ悲報】『2択を外し続けるマン』👈誰が思い浮かんだ? [762037879]
- 結局高市政権を批判したのはチャンネル桜だけだったね。 [134367759]
- 愛のままにわがままに👶は👶🏿だけを傷つけないお🏡
