home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / mmap1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  1KB  |  37 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <map>
  5. #include <iostream>
  6.  
  7. #ifdef MAIN 
  8. #define mmap1_test main
  9. #endif
  10.  
  11. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  12. using namespace std;
  13. #endif
  14. int mmap1_test(int, char**)
  15. {
  16.   cout<<"Results of mmap1_test:"<<endl;
  17.   typedef multimap<char, int, less<char> > mmap;
  18.   mmap m;
  19.   cout << "count('X') = " << m.count('X') << endl;
  20.   m.insert(pair<const char, int>('X', 10)); // Standard way.
  21.   cout << "count('X') = " << m.count('X') << endl;
  22. //  m.insert('X', 20); // Non-standard, but very convenient!
  23.   m.insert(pair<const char, int>('X', 20));    // jbuck: standard way
  24.   cout << "count('X') = " << m.count('X') << endl;
  25. //  m.insert('Y', 32);
  26.   m.insert(pair<const char, int>('Y', 32));    // jbuck: standard way
  27.   mmap::iterator i = m.find('X'); // Find first match.
  28.   while(i != m.end()) // Loop until end is reached.
  29.   {
  30.     cout <<(*i).first << " -> " <<(*i).second << endl;
  31.     i++;
  32.   }
  33.   int count = m.erase('X');
  34.   cout << "Erased " << count << " items" << endl;
  35.   return 0;
  36. }
  37.