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

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <algorithm>
  7.  
  8. #ifdef MAIN 
  9. #define vec6_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15. int vec6_test(int, char**)
  16. {
  17.   cout<<"Results of vec6_test:"<<endl;
  18. int array [] = { 1, 4, 9, 16, 25, 36 };
  19.  
  20.   vector<int> v(array, array + 6);
  21.   int i;
  22.   for(i = 0; i < v.size(); i++)
  23.     cout << "v[" << i << "] = " << v[i] << endl;
  24.   cout << endl;
  25.   v.erase(v.begin()); // Erase first element.
  26.   for(i = 0; i < v.size(); i++)
  27.     cout << "v[" << i << "] = " << v[i] << endl;
  28.   cout << endl;
  29.   v.erase(v.end() - 1); // Erase last element.
  30.   for(i = 0; i < v.size(); i++)
  31.     cout << "v[" << i << "] = " << v[i] << endl;
  32.   cout << endl;
  33.   v.erase(v.begin() + 1, v.end() - 1); // Erase all but first and last.
  34.   for(i = 0; i < v.size(); i++)
  35.     cout << "v[" << i << "] = " << v[i] << endl;
  36.   cout << endl;
  37.   /*
  38.   v.erase(v.begin(), v.end()); // Erase all.
  39.   */
  40.   return 0;
  41. }
  42.