迭代器vs reverse_iterator [英] iterator vs reverse_iterator
问题描述
我正在使用 std :: map
来存储很多元素(成对的元素),并且我有一个小"疑问.在我的 std :: map
, iterator
或 reverse_iterator
上迭代所有元素的效率更高?
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 std::map
, iterator
or reverse_iterator
?
推荐答案
真的重要吗?这些是您必须避免使用IMHO的微优化的类型.同样,即使对于地图中大量元素的迭代时间发生了变化,您试图遍历如此大地图中所有元素的事实也意味着您很可能选择了错误的数据结构.
Does it really matter? these are the types of the micro optimizations you must try to avoid IMHO. Also, even if the iteration time changes for very large number of elements in the map, the fact that you are trying to iterate through all the elements of such a big map means that most probably you have chosen a wrong data structure.
这篇关于迭代器vs reverse_iterator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!