t*i 发帖数: 72 | 1 How to iterator through a vector, list and map? What is the difference among
them?
到底有啥区别么? | O*******d 发帖数: 20343 | 2 You can use index to access members of a vector as if it is an array. You
can use key to access members of a map.
You can use iterator to access members of all three of them.
index and key are fast, while iterator is slow. | t****t 发帖数: 6806 | 3 the good thing about iterator is that, you have consistent interface(s) to
iterate through a container, be it sequential or associative. you may even
access something that is not a container via iterator and adaptor, e.g.
ostream_iterator.
for difference, vector,list and map iterators are all bidirectional
iterators. vector::iterator is random in addition, however.
among
【在 t*i 的大作中提到】 : How to iterator through a vector, list and map? What is the difference among : them? : 到底有啥区别么?
| t*i 发帖数: 72 | 4 Thank you so much.
【在 O*******d 的大作中提到】 : You can use index to access members of a vector as if it is an array. You : can use key to access members of a map. : You can use iterator to access members of all three of them. : index and key are fast, while iterator is slow.
| t*i 发帖数: 72 | 5 Thank you so much
【在 t****t 的大作中提到】 : the good thing about iterator is that, you have consistent interface(s) to : iterate through a container, be it sequential or associative. you may even : access something that is not a container via iterator and adaptor, e.g. : ostream_iterator. : for difference, vector,list and map iterators are all bidirectional : iterators. vector::iterator is random in addition, however. : : among
|
|