Resize STL Vector

I can not find this information. I am dealing with a strange situation here, where I am inside the loop, and I can get random information at any given time. This information should be stored in a vector. Now, for each frame, I must set this vector to ensure that I will not extract the space (I write values ​​to random points in the vector using indexing).

Now, believing that there is no way to change this piece of code, I want to know if the vector "ignores" the resize () function if I send an argument that exactly matches the size of the vector? Where can I find this information?

+5
source share
2 answers

From MSDN link 1

, _Newsize, , . , , , , _Newsize. ,

ISO ++ (. 485 2) vector::resize

void resize ( size_type sz , T c = T ());

if ( sz > size ())
  insert ( end () , sz - size () , c );
else if ( sz < size ())
  erase ( begin ()+ sz , end ());
else
; // Does nothing

, , , .

+9

-.

resize() , (, ). , ( , ). , , .

, , , , , . _M_buff [i]. ~ T() , . , , , , , , ( ), . , , - , , .

0

All Articles