A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2Fmap_multimap%2Fmap_iterator</id>
		<title>C++ Tutorial/map multimap/map iterator - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2Fmap_multimap%2Fmap_iterator"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/map_multimap/map_iterator&amp;action=history"/>
		<updated>2026-04-10T18:51:10Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/map_multimap/map_iterator&amp;diff=2085&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/map_multimap/map_iterator&amp;diff=2085&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/map_multimap/map_iterator&amp;diff=2086&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/map_multimap/map_iterator&amp;diff=2086&amp;oldid=prev"/>
				<updated>2010-05-25T10:28:49Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==const_iterator for map==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
typedef map &amp;lt;int, string&amp;gt; MAP_INT_STRING;&lt;br /&gt;
typedef multimap &amp;lt;int, string&amp;gt; MMAP_INT_STRING;&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
    MAP_INT_STRING mapIntToString;&lt;br /&gt;
    mapIntToString.insert (MAP_INT_STRING::value_type (3, &amp;quot;Three&amp;quot;));&lt;br /&gt;
    MAP_INT_STRING::const_iterator iMapPairLocator;&lt;br /&gt;
    for ( iMapPairLocator = mapIntToString.begin (); iMapPairLocator != mapIntToString.end (); ++ iMapPairLocator )&lt;br /&gt;
    {&lt;br /&gt;
        cout &amp;lt;&amp;lt; &amp;quot;Key: &amp;quot; &amp;lt;&amp;lt; iMapPairLocator-&amp;gt;first;&lt;br /&gt;
        cout &amp;lt;&amp;lt; &amp;quot; Value: &amp;quot; &amp;lt;&amp;lt; iMapPairLocator-&amp;gt;second.c_str ();&lt;br /&gt;
        cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create int string map and print all element pair==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;The C++ Standard Library - A Tutorial and Reference&amp;quot;&lt;br /&gt;
 * by Nicolai M. Josuttis, Addison-Wesley, 1999&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright Nicolai M. Josuttis 1999.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    // type of the collection&lt;br /&gt;
    typedef multimap&amp;lt;int,string&amp;gt; IntStringMMap;&lt;br /&gt;
    IntStringMMap coll;        // container for int/string values&lt;br /&gt;
    // insert some elements in arbitrary order&lt;br /&gt;
    // - a value with key 1 gets inserted twice&lt;br /&gt;
    coll.insert(make_pair(5,&amp;quot;tagged&amp;quot;));&lt;br /&gt;
    coll.insert(make_pair(2,&amp;quot;a&amp;quot;));&lt;br /&gt;
    coll.insert(make_pair(1,&amp;quot;this&amp;quot;));&lt;br /&gt;
    coll.insert(make_pair(4,&amp;quot;of&amp;quot;));&lt;br /&gt;
    coll.insert(make_pair(6,&amp;quot;strings&amp;quot;));&lt;br /&gt;
    coll.insert(make_pair(1,&amp;quot;is&amp;quot;));&lt;br /&gt;
    coll.insert(make_pair(3,&amp;quot;multimap&amp;quot;));&lt;br /&gt;
    /* print all element values&lt;br /&gt;
     * - iterate over all elements&lt;br /&gt;
     * - element member second is the value&lt;br /&gt;
     */&lt;br /&gt;
    IntStringMMap::iterator pos;&lt;br /&gt;
    for (pos = coll.begin(); pos != coll.end(); ++pos) {&lt;br /&gt;
        cout &amp;lt;&amp;lt; pos-&amp;gt;second &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;this is a multimap of tagged strings&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Cycle through the map in the reverse direction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;utility&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void show(const char *msg, map&amp;lt;string, string&amp;gt; mp);&lt;br /&gt;
int main() {&lt;br /&gt;
  map&amp;lt;string, string&amp;gt; phonemap;&lt;br /&gt;
  phonemap[&amp;quot;A&amp;quot;] = &amp;quot;444-555-1234&amp;quot;;&lt;br /&gt;
  phonemap[&amp;quot;B&amp;quot;] = &amp;quot;555-555-6576&amp;quot;;&lt;br /&gt;
  phonemap[&amp;quot;C&amp;quot;] = &amp;quot;555-555-9843&amp;quot;;&lt;br /&gt;
  show(&amp;quot;Here is the original map: &amp;quot;, phonemap);&lt;br /&gt;
  phonemap[&amp;quot;B&amp;quot;] = &amp;quot;555 555-5555&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;New number: &amp;quot; &amp;lt;&amp;lt; phonemap[&amp;quot;B&amp;quot;] &amp;lt;&amp;lt; endl;&lt;br /&gt;
  // Cycle through the map in the reverse direction.&lt;br /&gt;
  map&amp;lt;string, string&amp;gt;::reverse_iterator ritr;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Display phonemap in reverse order:&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  for(ritr = phonemap.rbegin(); ritr != phonemap.rend(); ++ritr)&lt;br /&gt;
     cout &amp;lt;&amp;lt; ritr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;: &amp;quot; &amp;lt;&amp;lt; ritr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
// Display the contents of a map&amp;lt;string, string&amp;gt; by using an iterator.&lt;br /&gt;
void show(const char *msg, map&amp;lt;string, string&amp;gt; mp) {&lt;br /&gt;
  map&amp;lt;string, string&amp;gt;::iterator itr;&lt;br /&gt;
  cout &amp;lt;&amp;lt; msg &amp;lt;&amp;lt; endl;&lt;br /&gt;
  for(itr=mp.begin(); itr != mp.end(); ++itr)&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;: &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declare an iterator to a map&amp;lt;string, int&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main() {&lt;br /&gt;
  map&amp;lt;string, int&amp;gt; m;&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;A&amp;quot;, 100));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;G&amp;quot;, 300));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;B&amp;quot;, 200));&lt;br /&gt;
  // Declare an iterator to a map&amp;lt;string, int&amp;gt;.&lt;br /&gt;
  map&amp;lt;string, int&amp;gt;::iterator itr;&lt;br /&gt;
  // Display the first element in m.&lt;br /&gt;
  itr = m.begin();&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Here is the first key/value pair in m: &amp;quot;&lt;br /&gt;
       &amp;lt;&amp;lt; itr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declare a reverse iterator to a map&amp;lt;string, itr&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main() {&lt;br /&gt;
  map&amp;lt;string, int&amp;gt; m;&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;A&amp;quot;, 100));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;G&amp;quot;, 300));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;B&amp;quot;, 200));&lt;br /&gt;
  // Declare an iterator to a map&amp;lt;string, int&amp;gt;.&lt;br /&gt;
  map&amp;lt;string, int&amp;gt;::iterator itr;&lt;br /&gt;
  // Declare a reverse iterator to a map&amp;lt;string, itr&amp;gt;.&lt;br /&gt;
  map&amp;lt;string, int&amp;gt;::reverse_iterator ritr;&lt;br /&gt;
  // show the contents of m in reverse order.&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;The contents of m in reverse:\n&amp;quot;;&lt;br /&gt;
  for(ritr=m.rbegin(); ritr != m.rend(); ++ritr)&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;  &amp;quot; &amp;lt;&amp;lt; ritr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; ritr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Display the first element in map==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main() {&lt;br /&gt;
  map&amp;lt;string, int&amp;gt; m;&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;A&amp;quot;, 100));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;G&amp;quot;, 300));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;B&amp;quot;, 200));&lt;br /&gt;
  // Declare an iterator to a map&amp;lt;string, int&amp;gt;.&lt;br /&gt;
  map&amp;lt;string, int&amp;gt;::iterator itr;&lt;br /&gt;
  // Display the first element in m.&lt;br /&gt;
  itr = m.begin();&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Here is the first key/value pair in m: &amp;quot;&lt;br /&gt;
       &amp;lt;&amp;lt; itr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Display the last element in map==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main() {&lt;br /&gt;
  map&amp;lt;string, int&amp;gt; m;&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;A&amp;quot;, 100));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;G&amp;quot;, 300));&lt;br /&gt;
  m.insert(pair&amp;lt;string, int&amp;gt;(&amp;quot;B&amp;quot;, 200));&lt;br /&gt;
  // Declare an iterator to a map&amp;lt;string, int&amp;gt;.&lt;br /&gt;
  map&amp;lt;string, int&amp;gt;::iterator itr;&lt;br /&gt;
  // Display the last element in m.&lt;br /&gt;
  itr = m.end();&lt;br /&gt;
  --itr;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Here is the last key/value pair in m: &amp;quot;&lt;br /&gt;
       &amp;lt;&amp;lt; itr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;second &amp;lt;&amp;lt; &amp;quot;\n\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Loop through map and print all the key/value pair==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
#include &amp;lt;map&amp;gt; // map class-template definition&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt; pairs;&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 15, 2.7 ) );&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 30, 111.11 ) );&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 0, 1010.1 ) );&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 10, 22.22 ) );&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 25, 33.333 ) );&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 0, 77.54 ) ); // dup ignored&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 20, 9.345 ) );&lt;br /&gt;
   pairs.insert( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::value_type( 15, 99.3 ) ); // dup ignored&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pairs contains:\nKey\tValue\n&amp;quot;;&lt;br /&gt;
   // use const_iterator to walk through elements of pairs&lt;br /&gt;
   for ( std::map&amp;lt; int, double, std::less&amp;lt; int &amp;gt; &amp;gt;::const_iterator iter = pairs.begin();&lt;br /&gt;
      iter != pairs.end(); ++iter )&lt;br /&gt;
      cout &amp;lt;&amp;lt; iter-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;\t&amp;quot; &amp;lt;&amp;lt; iter-&amp;gt;second &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;pairs contains:&lt;br /&gt;
Key     Value&lt;br /&gt;
0       1010.1&lt;br /&gt;
10      22.22&lt;br /&gt;
15      2.7&lt;br /&gt;
20      9.345&lt;br /&gt;
25      33.333&lt;br /&gt;
30      111.11&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==reverse_iterator from map==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;utility&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void show(const char *msg, map&amp;lt;string, string&amp;gt; mp);&lt;br /&gt;
int main() {&lt;br /&gt;
  map&amp;lt;string, string&amp;gt; phonemap;&lt;br /&gt;
  phonemap[&amp;quot;A&amp;quot;] = &amp;quot;444-555-1234&amp;quot;;&lt;br /&gt;
  phonemap[&amp;quot;B&amp;quot;] = &amp;quot;555-555-6576&amp;quot;;&lt;br /&gt;
  phonemap[&amp;quot;C&amp;quot;] = &amp;quot;555-555-9843&amp;quot;;&lt;br /&gt;
  show(&amp;quot;Here is the original map: &amp;quot;, phonemap);&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
  phonemap[&amp;quot;B&amp;quot;] = &amp;quot;555 555-5555&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;New number for B: &amp;quot; &amp;lt;&amp;lt; phonemap[&amp;quot;B&amp;quot;] &amp;lt;&amp;lt; endl;&lt;br /&gt;
  // Use find() to find a number.&lt;br /&gt;
  map&amp;lt;string, string&amp;gt;::iterator itr;&lt;br /&gt;
  itr = phonemap.find(&amp;quot;A&amp;quot;);&lt;br /&gt;
  if(itr != phonemap.end())&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Number for A is &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  // Cycle through the map in the reverse direction.&lt;br /&gt;
  map&amp;lt;string, string&amp;gt;::reverse_iterator ritr;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Display phonemap in reverse order:&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  for(ritr = phonemap.rbegin(); ritr != phonemap.rend(); ++ritr)&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; ritr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;: &amp;quot; &amp;lt;&amp;lt; ritr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
// Display the contents of a map&amp;lt;string, string&amp;gt; by using an iterator.&lt;br /&gt;
void show(const char *msg, map&amp;lt;string, string&amp;gt; mp) {&lt;br /&gt;
  map&amp;lt;string, string&amp;gt;::iterator itr;&lt;br /&gt;
  cout &amp;lt;&amp;lt; msg &amp;lt;&amp;lt; endl;&lt;br /&gt;
  for(itr=mp.begin(); itr != mp.end(); ++itr)&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;: &amp;quot; &amp;lt;&amp;lt; itr-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use iterator to loop through map and print all elements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;The C++ Standard Library - A Tutorial and Reference&amp;quot;&lt;br /&gt;
 * by Nicolai M. Josuttis, Addison-Wesley, 1999&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright Nicolai M. Josuttis 1999.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    /* type of the container:&lt;br /&gt;
     * - map: elements key/value pairs&lt;br /&gt;
     * - string: keys have type string&lt;br /&gt;
     * - float: values have type float&lt;br /&gt;
     */&lt;br /&gt;
    typedef map&amp;lt;string,float&amp;gt; StringFloatMap;&lt;br /&gt;
    StringFloatMap coll;&lt;br /&gt;
    // insert some elements into the collection&lt;br /&gt;
    coll[&amp;quot;VAT&amp;quot;] = 0.15;&lt;br /&gt;
    coll[&amp;quot;Pi&amp;quot;] = 3.1415;&lt;br /&gt;
    coll[&amp;quot;an arbitrary number&amp;quot;] = 4983.223;&lt;br /&gt;
    coll[&amp;quot;Null&amp;quot;] = 0;&lt;br /&gt;
    /* print all elements&lt;br /&gt;
     * - iterate over all elements&lt;br /&gt;
     * - element member first is the key&lt;br /&gt;
     * - element member second is the value&lt;br /&gt;
     */&lt;br /&gt;
    StringFloatMap::iterator pos;&lt;br /&gt;
    for (pos = coll.begin(); pos != coll.end(); ++pos) {&lt;br /&gt;
        cout &amp;lt;&amp;lt; &amp;quot;key: \&amp;quot;&amp;quot; &amp;lt;&amp;lt; pos-&amp;gt;first &amp;lt;&amp;lt; &amp;quot;\&amp;quot; &amp;quot;&lt;br /&gt;
             &amp;lt;&amp;lt; &amp;quot;value: &amp;quot; &amp;lt;&amp;lt; pos-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;key: &amp;quot;Null&amp;quot; value: 0&lt;br /&gt;
key: &amp;quot;Pi&amp;quot; value: 3.1415&lt;br /&gt;
key: &amp;quot;VAT&amp;quot; value: 0.15&lt;br /&gt;
key: &amp;quot;an arbitrary number&amp;quot; value: 4983.22&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>