3 ms·
My experience exactly. Recent code I had to change map<string, int> to MSVC specific hash_map<string, int> because the hash-implementation was better in the cas
by malkia 16y ago
My experience exactly. Recent code I had to change map<string, int> to MSVC specific hash_map<string, int> because the hash-implementation was better in the case, rather than the tree in the first case (not sure whether it's avl or red-black).
I really did not care about ordering.
And then std::string. I had to go and pool a lot of the std::string's that we have in one of our tools through a function (reusing common lisp) called intern, that was storing them in a pool without reference counting - this saved quite a lot of memory (most of them were key-values pairs).
- briansmith 16y agoFor the first problem, see std::unordered_map (was std::tr1::unordered_map). For the second problem, see boost::flyweight<std::string>. And/or, "typedef std::shared_ptr<std::string> string" and add "new" in front of every string you create.
- malkia 16y agoFunny, a colleague just used std::tr1:unordered_map, and it was available in his VS2008 (I guess SP1), but not on everyone's machine. Yes, it seems to be the right thing - unordered, while hash_map is still ordered (it wants less operator).