C++ STL Map vs Vector speed

后端 未结 12 1078
日久生厌
日久生厌 2020-12-16 11:56

In the interpreter for my experimental programming language I have a symbol table. Each symbol consists of a name and a value (the value can be e.g.: of type string, int, fu

12条回答
  •  一个人的身影
    2020-12-16 12:18

    Map's operator [] is O(log(n)), see wikipedia : http://en.wikipedia.org/wiki/Map_(C%2B%2B)

    I think as you're looking often for symbols, using a map is certainly right. Maybe a hash map (std::unordered_map) could make your performance better.

提交回复
热议问题