// main.cpp // cxx -w0 -std strict_ansi main.cpp Vector.cpp Node.cpp // Iterator.cpp // // input: primary.input // output: primary.output #include #include "Vector.h" #include "Iterator.h" using namespace std; int main() { Vector v1; Iterator it; // test reader, count, front, back and end() v1.reader(); cout << "count = " << v1.size() << endl; cout << "front = " << v1.front() << endl; cout << "back = " << v1.back() << endl; cout << "end() = " << *v1.end() << endl; cout << "v1: "; v1.print(); // erase 1st node it = v1.begin(); v1.erase(it); cout << "v1: "; v1.print(); // erase last node it = v1.begin() + (v1.size()-1); v1.erase(it); cout << "v1: "; v1.print(); // test popback() v1.popback(); v1.popback(); cout << "v1: "; v1.print(); // insert at beginning v1.insert(v1.begin(), "here"); cout << "v1: "; v1.print(); // test find // insert in middle it = find(v1.begin(), v1.end(), "UMD"); v1.insert(it,"there"); cout << "v1: "; v1.print(); // insert at end v1.insert(v1.end(),"everywhere"); cout << "v1: "; v1.print(); // empty vector/list v1.popback(); v1.popback(); v1.popback(); v1.popback(); v1.popback(); v1.popback(); v1.popback(); cout << "count = " << v1.size() << endl; cout << "v1: "; v1.print(); // test isEmpty() if (v1.isEmpty()) cout << "empty vector" << endl; return 0; }