Thursday, August 12, 2010

at() and operator[]() Functions

Vectors and deques provide the at() and operator[]() functions. Having these functions happens to correspond with containers that have Random Access Iterators, with one exception. map has operator[](), but does not have a random access iterator. Map's operator[]() does not execute in constant time, O(1); whereas containers with random access iterators are able to execute in constant time.

Reference: The C++ Standard Library by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 162.

No comments:

Post a Comment