What data structure is inside std::map in C++?

前端 未结 6 910
余生分开走
余生分开走 2020-12-03 11:34

I\'m beginner and learning C++ Having hard times to understand std::map concepts, because the code I\'m playing with implies that the map is a search tree, i.e.

6条回答
  •  执笔经年
    2020-12-03 11:52

    std::map is an associative container. The only requirement by the standard is that the container must have an associative container interface and behavior, the implementation is not defined. While the implementation fits the complexity and interface requirements, is a valid implementation.

    On the other hand, std::map is usually implemented with a red-black tree, as the reference says.

提交回复
热议问题