title: How to get random and unique values from a vector?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/196017/unique-random-numbers-in-o1">Unique random numbers in O(1)?</a><br>
    <a href="https://stackoverflow.com/questions/1608181/unique-random-numbers-in-an-integer-array-in-the-c-programming-language">Unique random numbers in an integer array in the C programming language</a>  </p>
  </blockquote>
  
  
  
  <p>I have a <code>std::vector</code> of unique elements of some undetermined size. I want to fetch 20 unique and random elements from this vector. By 'unique' I mean that I do not want to fetch the same index more than once. Currently the way I do this is to call <code>std::random_shuffle</code>. But this requires me to shuffle the entire vector (which may contain over 1000 elements). I don't mind mutating the vector (I prefer not to though, as I won't need to use thread locks), but most important is that I want this to be efficient. I shouldn't be shuffling more than I need to.</p>
  
  <p>Note that I've looked into passing in a partial range to <code>std::random_shuffle</code> but it will only ever shuffle that subset of elements, which would mean that the elements outside of that range never get used!</p>
  
  <p>Help is appreciated. Thank you!</p>
  
  <p>Note: I'm using Visual Studio 2005, so I do not have access to C++11 features and libraries.</p>