| 1 |
#include <iostream> |
| 2 |
#include <string> |
| 3 |
#include "Vector.h" |
| 4 |
|
| 5 |
int main() |
| 6 |
{ |
| 7 |
Vector<int> |
| 8 |
bv(5), |
| 9 |
b2; |
| 10 |
|
| 11 |
b2 = bv; |
| 12 |
|
| 13 |
bv[0] = 3; |
| 14 |
bv[1] = 33; |
| 15 |
bv[2] = 13; |
| 16 |
bv[3] = 6; |
| 17 |
bv[4] = 373; |
| 18 |
|
| 19 |
copy(bv.begin(), bv.end(), ostream_iterator<int>(cout, " ")); |
| 20 |
cout << '\n'; |
| 21 |
|
| 22 |
Vector<int>::reverse_iterator |
| 23 |
rit = bv.rbegin(); |
| 24 |
|
| 25 |
while (rit != bv.rend()) |
| 26 |
cout << *rit++ << ", "; |
| 27 |
cout << '\n'; |
| 28 |
|
| 29 |
bv.push_back(12); |
| 30 |
bv.push_back(5); |
| 31 |
|
| 32 |
copy(bv.begin(), bv.end(), ostream_iterator<int>(cout, " ")); |
| 33 |
cout << '\n'; |
| 34 |
|
| 35 |
bv.sort(); |
| 36 |
copy(bv.begin(), bv.end(), ostream_iterator<int>(cout, " ")); |
| 37 |
cout << "bv has " << bv.size() << " elements\n"; |
| 38 |
|
| 39 |
Vector<string> |
| 40 |
bstr; |
| 41 |
|
| 42 |
bstr.push_back("bravo"); |
| 43 |
bstr.push_back("delta"); |
| 44 |
bstr.push_back("foxtrot"); |
| 45 |
bstr.push_back("echo"); |
| 46 |
bstr.push_back("charley"); |
| 47 |
bstr.push_back("alpha"); |
| 48 |
|
| 49 |
bstr.sort(); |
| 50 |
copy(bstr.begin(), bstr.end(), ostream_iterator<string>(cout, " ")); |
| 51 |
cout << '\n'; |
| 52 |
} |