std::vector fast access

C

Chris Forone

hello group,

for std::vector, what access is faster from experience, the index or via
iterator?

thanks!

cheers, chris
 
J

Juha Nieminen

Chris said:
for std::vector, what access is faster from experience, the index or via
iterator?

Why don't you measure it?

In most implementations, when not compiling in debug mode, indexing a
std::vector is basically a "pointer[index]" operation, and using an
iterator is identical to using a pointer. Which one is faster depends on
a lot of things.
 
D

Daniel T.

for std::vector, what access is faster from experience, the index or via
iterator?

I'd be suprised if there is any measurable difference at all,
especially in a real world application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top