title: Is it more efficient to preallocate a vector?
body: <p>In C++ Primer fourth edition, by Stanley B.Lippman, Josee Lajoie and Barbara E. Moo it states:</p>
  
  <blockquote>
    <p>Because vectors grow efficiently, it is usually best to let the vector
    grow by adding elements to it dynamically as the element values are
    known.</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>Readers accustomed to using c or java might expect that because vector
    elements are stored contiguously, it would be best to preallocate the
    vector at its expected size. In fact the contrary is the case...</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>Allthough we can preallocate a given number of elements in a vector,
    it is usually more efficient to define an empty vector and add
    elements to it.</p>
  </blockquote>
  
  <p>Assuming this is correct (the authors are as reputable as they come, one is a co-author of C++ itself) then can anyone give me a case that proves this statement, and explain why?</p>