iterator vs reverse_iterator

前端 未结 6 1571
暗喜
暗喜 2021-01-05 05:52

I\'m using std::map to store a lot of elements (pairs of elements) and I have a \"little\" doubt. What is more efficient to iterate all elements over my

6条回答
  •  太阳男子
    2021-01-05 06:11

    I am wondering the need for iteration. Map holds the key-value pairs and normally you use it for the lookup. If you still need to iterate the map for some reasons ( may be deleting pointers contained inside the map etc) then you can use std::for_each. Forget the micro optimizations and you can try to increase the code readability.

提交回复
热议问题