title: Print size of a vector through an iterator
body: <p>I'm trying to print the <strong>size</strong> of a <code>vector</code>. Sounds easy, but the vector is in a <code>map</code>.
  Currently I have an iterator on a map looking like this:<br>
  <code>map&lt;string, vector&lt;map&lt;vector&lt;string&gt; , vector&lt;string&gt; &gt; &gt; &gt;::iterator it;</code>  </p>
  
  <p>I am trying to display the size like this:</p>
  
  <hr>
  
  <p><strong>EDIT:</strong><br>
  The iterator is intialised like this: <code>it = csvMap.find(commandList.at(lineCount));</code></p>
  
  <hr>
  
  <p><code>cout&lt;&lt;"Size of vector in Map  after modifying: " &lt;&lt; it-&gt;second.size() &lt;&lt;"\n"&lt;&lt;endl;</code></p>
  
  <p>It's not working, the program crashes.
  I think a way would be to make a <strong>temp vector</strong> and fill it with the value <code>it-&gt;second;</code>
  But just to get the size is kind of wasting space isn't it?</p>
  
  <p>Is there a better way to do so?</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p><strong>EDIT2:</strong> removed old code</p>
  
  <hr>
  
  <p><strong>EDIT 3:</strong> new code:  </p>
  
  <pre><code>            map&lt;vector&lt;string&gt; , vector&lt;string&gt; &gt; parameterMap;
          parameterMap.insert(pair&lt;vector&lt;string&gt; , vector&lt;string&gt; &gt; (
              part1_input, part2_output));
  
          map&lt;string, vector&lt;map&lt;vector&lt;string&gt; , vector&lt;string&gt; &gt; &gt; &gt;::iterator it;
  
          cout&lt;&lt;"\nSize of CSV Map  before modifying: " &lt;&lt; csvMap.size() &lt;&lt;endl;
          //cout&lt;&lt;"Size of vector in CSV Map  before modifying: " &lt;&lt; it-&gt;second.size() &lt;&lt;"\n"&lt;&lt;endl;
  
  
          if(csvMap.size() == 0)
          {
              /*
              * csvMap is empty -&gt; no need to search for something. Just insert the fist entries
              */
              listedParameterMap.insert(listedParameterMap.end(), 1, parameterMap);
              csvMap.insert(pair&lt;string, vector&lt;map&lt;vector&lt;string&gt; ,
                  vector&lt;string&gt; &gt; &gt; &gt; (commandList[lineCount],
                  listedParameterMap));
              cout&lt;&lt;"CSV Map size: " &lt;&lt; csvMap.size() &lt;&lt;endl;
          }
          else
          {
              /* 
              * Search if the Command is already available, if not,
              * add it to the map with its corresponding list of maps (in/output values)
              * find returns map::end if key is not found
              */
  
              cout&lt;&lt;"Checking if: " &lt;&lt; commandList.at(lineCount) &lt;&lt; " is already in the list \n" &lt;&lt; endl;
              it = csvMap.find(commandList.at(lineCount));
              if (it == csvMap.end())
              {
                  /*
                  * it = csvMap.end() is true
                  * The command isn't found
                  */
  
                  cout&lt;&lt; commandList.at(lineCount) &lt;&lt; " command not available. Inserting it! \n" &lt;&lt; endl;
                  listedParameterMap.insert(listedParameterMap.end(), 1, parameterMap);
                  csvMap.insert(pair&lt;string, vector&lt;map&lt;vector&lt;string&gt; ,
                  vector&lt;string&gt; &gt; &gt; &gt; (commandList[lineCount],
                  listedParameterMap));
              }   
              else
              {
                  /*
                  * it != csvMap.end()
                  * The command is found. Append the parameterMap to the vector in the map
                  */
                  cout&lt;&lt; commandList.at(lineCount) &lt;&lt; " is already in the list! Appending parameters on pos: "&lt;&lt; it-&gt;second.size()-1&lt;&lt; "\n" &lt;&lt; endl;
                  it-&gt;second.push_back(parameterMap);
              }
          }
          cout&lt;&lt;"\nSize of CSV Map  after modifying: " &lt;&lt; csvMap.size() &lt;&lt;endl;
          cout&lt;&lt;"Size of vector in CSV Map  after modifying: " &lt;&lt; it-&gt;second.size() &lt;&lt;"\n"&lt;&lt;endl;
  </code></pre>
  
  <hr>
  
  <p>I hope someone is still reading this...</p>
  
  <p>I found now that <code>it.second</code> seems to be the problem on the first interation. But I don't get why.<br>
  Code snippet (also in the code above):</p>
  
  <pre><code>if(csvMap.size() == 0)
          {
              /*
              * csvMap is empty -&gt; no need to search for something. Just insert the fist entries
              */
              listedParameterMap.insert(listedParameterMap.end(), 1, parameterMap);
              csvMap.insert(pair&lt;string, vector&lt;map&lt;vector&lt;string&gt; ,
                  vector&lt;string&gt; &gt; &gt; &gt; (commandList[lineCount],
                  listedParameterMap));
              cout&lt;&lt;"CSV Map size: " &lt;&lt; csvMap.size() &lt;&lt;endl;
              cout&lt;&lt;"listedParameterMap: " &lt;&lt; listedParameterMap.size() &lt;&lt;endl;
              cout&lt;&lt; commandList.at(lineCount) &lt;&lt; " is already in the list! Appending parameters on pos: "&lt;&lt; it-&gt;second.size()&lt;&lt; "\n" &lt;&lt; endl;
          }
  </code></pre>
  
  <p><strong>This seems not to work. Although its goning into it. Any idea why?</strong>
  comanndList and listedParameterMap are as far as I see OK.</p>