I have a vector with 1000 ‘nodes’
if(count + 1 > m_listItems.capacity()) m_listItems.reserve(count + 100);
The problem is I also clear it out when I’m about to refill it.
m_listItems.clear();
The capacity doesn’t change. I’ve used the resize(1); but that doesn’t seem to alter the capacity. So how does one change the reserve?
will shrink
m_listItemsagain: http://www.gotw.ca/gotw/054.htm (Herb Sutter)If you want to clear it anyway, swap with an empty vector:
which of course is way more efficient. (Note that swapping vectors basicially means just swapping two pointers. Nothing really time consuming going on)