home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / test / regression / hmset1.cpp < prev    next >
C/C++ Source or Header  |  2002-05-05  |  2KB  |  59 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <iostream>
  5. #include <hash_set>
  6.  
  7. #ifdef MAIN 
  8. #define hmset1_test main
  9. #endif
  10.  
  11. // struct hash<string> {
  12. //      size_t operator()(const string& s) const { return __stl_hash_string(s.c_str()); }
  13. //};
  14.  
  15. #if defined (__MVS__)
  16.   #define star   92 
  17. #else
  18.   #define star   42
  19. //TORLAB DEBUG original #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  20. //TORLAB DEBUG original using namespace std;
  21. //TORLAB DEBUG original #endif
  22. #endif
  23.  
  24. // TORLAB DEBUG, we believe the 3 lines below were incorrectly place inside the
  25. // #else of the above #if block.
  26.  
  27. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  28. using namespace std;
  29. #endif
  30.  
  31. typedef hash_multiset<char, hash<char>, equal_to<char> > hmset;
  32.  
  33. // __STL_TYPE_TRAITS_POD_SPECIALIZE(_Hashtable_node<char>*);
  34.  
  35.  
  36. int hmset1_test(int, char**)
  37. {
  38.   cout<<"Results of hmset1_test:"<<endl;
  39.   hmset s;
  40.   cout << "count(" << star << ") = " << s.count(star) << endl;
  41.   s.insert(star);
  42.   cout << "count(" << star << ") = " << s.count(star) << endl;
  43.   s.insert(star);
  44.   cout << "count(" << star << ") = " << s.count(star) << endl;
  45.   hmset::iterator i = s.find(40);
  46.   if(i == s.end())
  47.     cout << "40 Not found" << endl;
  48.   else
  49.     cout << "Found " << *i << endl;
  50.   i = s.find(star);
  51.   if(i == s.end())
  52.     cout << "Not found" << endl;
  53.   else
  54.     cout << "Found " << *i << endl;
  55.   int count = s.erase(star);
  56.   cout << "Erased " << count << " instances" << endl;
  57.   return 0;
  58. }
  59.