Re: std::vector memory allocation
On Wed, 25 Jun 2003 13:57:31 +0100, onion_skin
>When a std::vector has to allocate more memory, am I correct in
>thinking that it allocates additional memory of equal size to the
>amount of memory required to store the existing number of elements?
No, it is implementation dependent, and it depends on why it has to
allocate memory (e.g. how many elements are being added, and how much
the current capacity is being exceeded by). In the case of a push_back
call, some implementations double the capacity, some use a different
factor, like 1.5, and some both double the size and add and extra bit
(like, say newcapacity = 2*currentcapacity + 5).
However, growth does have to be at least exponential to meet the
|All times are GMT. The time now is 11:12 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.