Ouch! Nice catch.
Originally Posted by
iMalc
There should only be one new allocation, of size 1024.
So like this?
Code:
// Count() is number of items in Array, count is number of items to be added....
if (Count() + count > Capacity())
{
int size = 8;
while (size < Count() + count)
{
size *= 2;
}
Reserve(size);
}
Edit:
BTW my array has default size of 10? Should it be 8?
Tried on std::vector... Here is what I got with MinGW... :?
Code:
std::vector<int> vec;
std::cout << vec.capacity(); // prints 0
I thought vector had a default capacity?