C ++ defines a data structure that preserves inserted order

Is there a built-in C ++ data structure that supports pasted order? It’s not a problem whether the set is a hash set or a set implemented by a balanced binary tree.

+4
source share
2 answers

In C ++ 11, it is guaranteed that both the order std::multisetand the std::multimapinsertion order of elements with the same score / key are saved .

Quote from the C ++ 11 standard,

23.2.4 Associative containers

4 , . , . ; . multiset multimap , .

, (-) std::unordered_multiset std::unordered_multimap ( ) .

+4
+1

All Articles