home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / parsrtc2.cpp < prev    next >
C/C++ Source or Header  |  2001-05-18  |  1KB  |  46 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <iterator>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <iostream>
  8. #include <cstring>
  9.  
  10. #ifdef MAIN 
  11. #define parsrtc2_test main
  12. #endif
  13.  
  14. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  15. using namespace std;
  16. #endif
  17.  
  18. static bool str_compare(const char* a_, const char* b_)
  19. {
  20.   return strcmp(a_, b_) < 0 ? 1 : 0;
  21. }
  22.  
  23. int parsrtc2_test(int, char**)
  24. {
  25.   cout<<"Results of parsrtc2_test:"<<endl;
  26.  
  27. char* names[] = { "aa", "ff", "dd", "ee", "cc", "bb" };
  28.  
  29.   const unsigned nameSize = sizeof(names) / sizeof(names[0]);
  30.   vector <char*> v1(nameSize);
  31.   for(int i = 0; i < v1.size(); i++)
  32.     v1[i] = names[i];
  33.   ostream_iterator<char*> iter(cout, " ");
  34.   copy(v1.begin(), v1.end(), iter);
  35.   cout << endl;
  36.   vector <char*> result(5);
  37.   partial_sort_copy(v1.begin(),
  38.                      v1.end(),
  39.                      result.begin(),
  40.                      result.end(),
  41.                      str_compare);
  42.   copy(v1.begin(), v1.end(), iter);
  43.   cout << endl;
  44.   return 0;
  45. }
  46.