The advance() function template, which is declared in the <iterator> header file has constant complexity for random access iterators, and linear complexity for all other iterators.
This is because advance() typically uses += for random access iterators, and a loop of ++ for the other iterators.
Reference: The C++ Standard Library: A Tutorial and Reference Nicolai M. Josuttis. Addison-Wesley, 1999, p. 259-260.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment