Is it faster to use iterators rather than random-access to access the elements of a vector, and if so is it really worth converting code to use iterators? (the code I'm considering changing is a matrix class)
Is it faster to use iterators rather than random-access to access the elements of a vector, and if so is it really worth converting code to use iterators? (the code I'm considering changing is a matrix class)
I would say no to both questions. Accessing a particular element might be faster using an iterator since you only have to dereference a pointer, compared to adding the offset to the first element of the array then dereferencing. But to increment an iterator might take longer because of the function call involved (mind you ive never looked at the asm code for this).
Even if using an iterator were faster, it would be by a miniscule amount and I dont see any reason to bother converting your code to gain slight performance.
C Code. C Code Run. Run Code Run... Please!
"Love is like a blackhole, you fall into it... then you get ripped apart"