title: Iterate over vector using first value of std::pair only
body: <p>I have a std::vector as described below:</p>
  
  <pre><code>std::vector&lt;std::pair&lt;int, const char*&gt;&gt; matrix;
  </code></pre>
  
  <p>This vector has the following values (for e.g.): <a href="http://i.stack.imgur.com/NiKaD.png" rel="nofollow">values (as an example)</a></p>
  
  <p>These values can be access here as follows:</p>
  
  <pre><code>matrix[0] = [0,Hello] // pseudo code (only showing values inside)
  
  matrix[1] = [0,Fox]  // pseudo code (only showing values inside)
  
  matrix[2] = [1,Red]  // pseudo code (only showing values inside)
  </code></pre>
  
  <p>I am iterating through the contents of the vector read the values, by doing this:</p>
  
  <pre><code>    for (std::vector&lt;std::pair&lt;int, const char*&gt;&gt;::iterator it = matrix.begin(); it != matrix.end(); ++it) 
      {
          std::pair&lt;int, const char*&gt; v_temp = *it;
          std::cout &lt;&lt; v_temp.first;
          std::cout &lt;&lt; v_temp.second;
      }
  </code></pre>
  
  <p>Now, what this is doing is iterating from the first element of vector to the end element of the vector. What I want to do, is iterate only on the first elements (i.e. int values). So, from the tabular image I have attached, this current code will loop for [ row x column ] [ 9 x 2] = 18 times. What I want it for it to iterate only 9 times [ rows ] and not consider columns at-all.</p>
  
  <p>How can I do that?</p>