PDA

View Full Version : what in Vector in C ++ 2011



Vuhelper
06-05-2011, 07:35 PM
Vectors are a kind of sequence container. As such, their elements are ordered following a strict linear sequence.

Vector containers are implemented as dynamic arrays; Just as regular arrays, vector containers have their elements stored in contiguous storage locations, which means that their elements can be accessed not only using iterators but also using offsets on regular pointers to elements.
http://t0.gstatic.com/images?q=tbn:ANd9GcQ-sqvKRyXWbnDOtYZPESDEfjCQ_uf96bzV-Ocwth0C6YBbqTGD
But unlike regular arrays, storage in vectors is handled automatically, allowing it to be expanded and contracted as needed.

Vectors are good at:

* Accessing individual elements by their position index (constant time).
* Iterating over the elements in any order (linear time).
* Add and remove elements from its end (constant amortized time).