How can I traverse/iterate an STL map?

前端 未结 6 622
栀梦
栀梦 2021-01-30 02:14

I want to traverse an STL map. I don\'t want to use its key. I don\'t care about the ordering, I just look for a way to access all elements it contains. How can I do this?

6条回答
  •  感动是毒
    2021-01-30 03:15

    As with any STL container, the begin() and end() methods return iterators that you can use to iterate over the map. Dereferencing a map iterator yields a std::pair.

提交回复
热议问题