What advantages are there in accessing vector elements using an iterator vs an index?
What advantages are there in accessing vector elements using an iterator vs an index?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why are iterators better than indexes?
example).
is called.
more than one container type.
all containers’ iterators as well as regular pointers in all standard
algorithms.
For instance, you can make an iterator class that steps through prime
numbers without actually having to build a container of primes.
However, if ignoring container types that do not support random access (list, set, etc.), iterators still offer
container.