title: How to iterate/count for a multimap<string,string>
body: <p>My class is like this:</p>
  
  <pre><code>class Outgoing
  {
      multimap&lt;string,string&gt; outgoing;
  
      public:
      void makeConnection(string key, string value)
      {
          outgoing.insert(pair&lt;string,string&gt;(key,value));
      }
  
      void iterate()
      {
          multimap&lt;string, string&gt;::iterator it;
          multimap&lt;string, string&gt;::iterator it2;
          pair&lt;multimap&lt;string,string&gt;::iterator,multimap&lt;string,string&gt;::iterator&gt; ret;
          for (it = outgoing.begin();it != outgoing.end();++it)
          {
              ret = outgoing.equal_range((*it));  ??????
              for (it2=ret.first; it2!=ret.second; ++it2)
              {
                  ???????
  
               }
          }
      }
  };
  </code></pre>
  
  <p>background:</p>
  
  <p>I want to represent a graph which can have many nodes. The key won't repeat but can have multiple values. </p>
  
  <pre><code>str1  ----&gt; val1
  str1  ----&gt; val2
  str2 -----&gt; val3
  </code></pre>
  
  <p>I want to know how can I get number of values for a particular key? for e.g. in the above question , for str1 it will be 2?</p>
  
  <p>As you can see , I tried to do something after some digging around but in vain.</p>
  
  <p>What is wrong with my code?</p>
  
  <p>thanks</p>
  
  <p>EDIT ::: after templatetypedef's comment, I edited the code to:</p>
  
  <pre><code>for (it = outgoing.begin();it != outgoing.end();++it)
  {
      cout&lt;&lt; (*it).first &lt;&lt; " "&lt;&lt;  outgoing.count((*it).first); 
  
  }
  </code></pre>
  
  <p>I can get the count, but the key("str1") comes twice. So the answer I see is 2 2 1.</p>
  
  <p>I would appreciate it very much, if somebody teaches me how to iterate in such a way I get only one key. BTW, thanks, templatetypedef</p>