title: How to make elements of vector unique? (remove non adjacent duplicates)
body: <p>I have a vector containing  few non-adjacent duplicates.</p>
  
  <p>As a simple example, consider:</p>
  
  <pre><code>2 1 6 1 4 6 2 1 1
  </code></pre>
  
  <p>I am trying to make this <code>vector</code> unique by removing the non-adjacent duplicates and maintaining the order of elements.</p>
  
  <p>Result would be:</p>
  
  <pre><code>2 1 6 4 
  </code></pre>
  
  <p>The solutions I tried are:</p>
  
  <ol>
  <li>Inserting into a std::set but the problem with this approach is that it will disturb the order of elements.</li>
  <li>Use the combination of std::sort and std::unique. But again same order problem.</li>
  <li><p>Manual duplicate elimination:</p>
  
  <pre><code>    Define a temporary vector TempVector.
      for (each element in a vector)
      {
          if (the element does not exists in TempVector)
          {
              add to TempVector;
          }
      }
      swap orginial vector with TempVector.
  </code></pre></li>
  </ol>
  
  <p>My question is:</p>
  
  <p>Is there any STL algorithm which can remove the non-adjacent duplicates from the vector ? what is its complexity?</p>