Hi all,
I know this is all very compiler/machine specific but...
how much space will
std::vector<int> aVector;
assign usually?
will my first aVector.push_back(n) have to assign memory before doing the push?
when aVector.push_back(n) is called repeatedly will it double the memory for the vector when needed or will it add blocks of some size?
eg.
std::vector<int> aVector;
aVector.reserve(1000);
The reserve() might not be necessary and could even be counter-productive if the definition assigns a block of 1024 anyway(?)
I'm searching an array for some condition that could appear once or 100000 times or not at all i.e I have no idea how big my vector will get but I don't want to assign 100000 places from the start. The process should be as fast as possible. Is it best to leave memory mangament to the machine, or should try to use reserve() cleverly?
thanks
K
Bookmarks