I am a little confused about memory reallocation in STL C++. For example, I know if I declare a vector
, and keep pushing back elements into it, the vector will at some point need a reallocation of memory space and copy all the existing elements into it. For linked lists no reallocation is needed, because the elements are not stored consecutively in the stack and each element uses a pointer to point to the next element.
My question is, what's the situation for other STL in C++ ? for example, string
, map
,unordered_map
? Do they need reallocation ?