title: working with two vectors - remove duplicates and merging
body: <p>I have two types of data sets. Both are in same size. One contains <code>vector&lt;int&gt;</code> and other contains <code>vector&lt;vector&lt;double&gt; &gt;</code>.
  When I moving forward one element by another, I can see some duplicates from my <code>vector&lt;int&gt;</code>. So, I want to delete the duplicate element (2nd element) from the <code>vector&lt;int&gt;</code> and keep the first element further. If I erase a duplicate element, then, at the same time, I want to merge the <code>vector&lt;double&gt;</code>, of corresponding two vectors, from my <code>vector&lt;vector&lt;double&gt; &gt;</code> data set. Once I merged, i want to delete 2nd <code>vector&lt;double&gt;</code> as it is already added to the previous <code>vector&lt;double&gt;</code>. By doing so, I want to maintain the equal size data sets further without having duplicates in first data set and without loosing any element from my second data set.</p>
  
  <p>I have implemented a simple code for that, but I think its logic is wrong. So, could you please help me to rectify this code?</p>
  
  <p><code>vector&lt;int&gt;</code> data set is assigned as my_list
  <code>vector&lt;vector&lt;double&gt; &gt;</code> data set is assigned as mydata</p>
  
  <p>For example, here is my two vectors</p>
  
  <pre><code>my_list  = {222, 208, 201, 201, 201, 206, 211, 222}
  mydata = {{a1,a2,a3},{b1,b2},{c1},{d1},{e1,e2},{f1,f2},{g1},{h1,h2,h3}}
  
  after, removing duplicate from the 1st vector and by merging corresponding vectors from 
  2nd data, the final output would be like as 
  my_list  = {222, 208, 201, 206, 211, 222}
  mydata = {{a1,a2,a3},{b1,b2},{c1, d1, e1,e2},{f1,f2},{g1},{h1,h2,h3}}
  
  
  
  
  vector&lt;int&gt;::iterator          no, no2;
  vector&lt;vector&lt;double&gt; &gt;::iterator  itr1, itr2;
  int i;
  
  for (no=my_list.begin(), no2=my_list.begin()+1, 
          itr1=mydata.begin(), itr2=mydata.begin()+1, i=0; no != my_list.end()-1;  ){
  
         if (*no == *no2){ //current = next 
            no2 = my_list.erase(no2);
  
            //add itr2 data to itr1 vector and erase itr2
            mydata[i].insert(mydata[i].end(), (*itr2).begin(), (*itr2).end()); 
            itr2 = mydata.erase(itr2);
         }
         else{
            ++no; ++no2;
            ++itr1; ++itr2;
            ++i;
         }
  }
  </code></pre>