home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / hmset1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  1KB  |  52 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.  
  20. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  21. using namespace std;
  22. #endif
  23. #endif
  24.  
  25. typedef hash_multiset<char, hash<char>, equal_to<char> > hmset;
  26. // __STL_TYPE_TRAITS_POD_SPECIALIZE(_Hashtable_node<char>*);
  27.  
  28.  
  29. int hmset1_test(int, char**)
  30. {
  31.   cout<<"Results of hmset1_test:"<<endl;
  32.   hmset s;
  33.   cout << "count(" << star << ") = " << s.count(star) << endl;
  34.   s.insert(star);
  35.   cout << "count(" << star << ") = " << s.count(star) << endl;
  36.   s.insert(star);
  37.   cout << "count(" << star << ") = " << s.count(star) << endl;
  38.   hmset::iterator i = s.find(40);
  39.   if(i == s.end())
  40.     cout << "40 Not found" << endl;
  41.   else
  42.     cout << "Found " << *i << endl;
  43.   i = s.find(star);
  44.   if(i == s.end())
  45.     cout << "Not found" << endl;
  46.   else
  47.     cout << "Found " << *i << endl;
  48.   int count = s.erase(star);
  49.   cout << "Erased " << count << " instances" << endl;
  50.   return 0;
  51. }
  52.