// MultimapExample.cpp

// The following program illustrates the use of multimaps
// in the STL using Visual C++.

// Author: Dr. Jeffrey Blessing

#pragma warning(disable: 4786)		// needed for MSVC++ STL
#include <map>
#include <string>
#include <iostream>
using namespace std;
void main()
{
   // Define a new type and name it StrIntMap
   typedef multimap<string, int> StrIntMap;

   // Create an instance of the multimap
   StrIntMap xref;

   // Populate the multimap using "value_type":
   xref.insert(StrIntMap::value_type("hello", 3));
   xref.insert(StrIntMap::value_type("world", 4));

   // Now add to the map using "pairs":
   pair<string, int> p;
   p.first = "goodbye";
   p.second = 5;
   xref.insert(p);	// some people think this way is more readable!

   pair<string, int> p2("cruel", 6);
   xref.insert(p2);

   // Iterate through the multimap, printing out the pairs

   for (StrIntMap::const_iterator it = xref.begin(); it != xref.end();  ++it)
   {
		cout << it->first << '\t' << it->second << endl;
   }

   // The rest of the program goes here!
}
