title: Finding the max value in a map
body: <p>I've been doing a basic program to find the max, min, median, variance, mode etc. of a vector. Everything went fine until I got to the mode.</p>
  <p>The way I see it, I should be able to loop through the vector, and for each number that occurs I increment a key on the map. Finding the key with the highest value would then be the one that occurred the most. Comparing to other keys would tell me if it's a single multiple or no mode answer.</p>
  <p>Here's the chunk of code that's been causing me so much trouble.</p>
  <pre><code>map&lt;int,unsigned&gt; frequencyCount;
  // This is my attempt to increment the values
  // of the map everytime one of the same numebers 
  for(size_t i = 0; i &lt; v.size(); ++i)
      frequencyCount[v[i]]++;
  
  unsigned currentMax = 0;
  unsigned checked = 0;
  unsigned maax = 0;
  for(auto it = frequencyCount.cbegin(); it != frequencyCount.cend(); ++it )
      //checked = it-&gt;second;
      if (it -&gt;second &gt; currentMax)
      {
          maax = it-&gt;first;
      }
      //if(it -&gt;second &gt; currentMax){
      //v = it-&gt;first
  
  cout &lt;&lt; &quot; The highest value within the map is: &quot; &lt;&lt; maax &lt;&lt; endl;
  </code></pre>
  <p>The entire program can be seen here. <a href="http://pastebin.com/MzPENmHp" rel="noreferrer">http://pastebin.com/MzPENmHp</a></p>