title: C++ understanding iter and erase
body: <p>I am just looking at a code, and I must say that I don't fully understand it yet.</p>
  
  <pre><code>vector&lt;long&gt;::iterator iter1;
  vector&lt;long&gt;::iterator iter2;
  
  while(m_vPitchMarks[0]&lt;=vPitchPeriode[0])
  {
      iter1 = m_vPitchMarks.begin();
      iter2 = vPitchPeriode.begin();
  
      m_vPitchMarks.erase(iter1);
      vPitchPeriode.erase(iter2);
      if((m_vPitchMarks.size()==0)||(vPitchPeriode.size()==0))
          break;
  }   
  </code></pre>
  
  <p>I am trying to break it down:</p>
  
  <p>Here we will do a while-statement while the value of the first element of m_vPitchMarks is smaller than the value of the first element of vPitchPeriod.</p>
  
  <pre><code>while(m_vPitchMarks[0]&lt;=vPitchPeriode[0])
  {
  }   
  </code></pre>
  
  <p>Here we set something like a reference to the first element (element at index [0]) of both vectors.</p>
  
  <pre><code>iter1 = m_vPitchMarks.begin();
  iter2 = vPitchPeriode.begin();
  </code></pre>
  
  <p>Now we erase all elements from m_vPitchMarks&lt;> that have just this value. 
  For example, if iter1 had a value of 15, all elements in m_vPitchMarks&lt;> that also have the value of 15 will be deleted, and the vector becomes shortened.</p>
  
  <pre><code>m_vPitchMarks.erase(iter1);
  vPitchPeriode.erase(iter2);
  </code></pre>
  
  <p>Is that correct?
  Thank you.</p>