How can I increase the performance in a map lookup with key type std::string?

后端 未结 14 1302
天涯浪人
天涯浪人 2021-02-05 23:25

I\'m using a std::map (VC++ implementation) and it\'s a little slow for lookups via the map\'s find method.

The key type is std::string.

14条回答
  •  感动是毒
    2021-02-05 23:44

    hash_map is not standard, try using unordered_map available in tr1 (which is available in boost if your tool chain doesn't already have it).

    For small numbers of strings you might be better using vector, as map is typically implemented as a tree.

提交回复
热议问题