469,898 Members | 1,503 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

std::vector fast access

hello group,

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

thanks!

cheers, chris
Jul 12 '08 #1
2 2354
Chris Forone wrote:
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.
Jul 12 '08 #2
On Jul 12, 6:11*am, Chris Forone <4...@gmx.atwrote:
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.
Jul 12 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Steve | last post: by
6 posts views Thread by isaacyho | last post: by
17 posts views Thread by Michael Hopkins | last post: by
8 posts views Thread by Ross A. Finlayson | last post: by
32 posts views Thread by zl2k | last post: by
21 posts views Thread by Peter Olcott | last post: by
9 posts views Thread by aaragon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.