I currently have a std::map<std::string,int>
that stores an integer value to an unique string identifier, and I do look up with the string. It does mostly what I want, except for that it does not keep track of the insertion order. So when I iterate the the map to print out the values, they are sorted according to the string; but I want them to be sorted according to the order of (first) insertion.
I thought about using a vector<pair<string,int>>
instead, but I need to look up the string and increment the integer values about 10,000,000 times, so I don't know whether a std::vector
will be significantly slower.
Is there a way to use std::map
or is there another std
container that better suits my need?
[I'm on GCC 3.4, and I have probably no more than 50 pairs of values in my std::map
].
Thanks.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…