title: C++: Assigning values to non-continuous indexes in vectors?
body: <p>If I want to declare a vector of unknown size, then assign values to index 5, index 10, index 1, index 100, in that order. Is it easily doable in a vector?</p>
  
  <p>It seems there's no easy way. Cause if I initialize a vector without a size, then I can't access index 5 without first allocating memory for it by doing resize() or five push_back()'s. But resize clears previously stored values in a vector. I can construct the vector by giving it a size to begin with, but I don't know how big the vector should. </p>
  
  <p>So how can I not have to declare a fixed size, and still access non-continuous indices in a vector?</p>
  
  <p>(I doubt an array would be easier for this task).</p>