///////////////////////////////////////////////////////////////// // collections.cpp - prototype to test design ideas // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2002 // ///////////////////////////////////////////////////////////////// #ifdef TEST_COLLECTIONS //----< test stub >-------------------------------------------- #include "collections.h" #include #include #include #include #include using namespace std; void main() { cout << "\n test collection class " << "\n =======================\n"; cout << "\n define a collection of somewhat miss-spelled Ardvaarks " << "\n --------------------------------------------------------"; collection coll; coll.push_back("ardvvark"); coll.insertElem("arddvark"); coll.insertElem("ardvaark"); cout << "\n display them using collection iterator " << "\n ----------------------------------------"; collection::iterator it; for(it=coll.begin(); it!=coll.end(); it++) cout << "\n " << *it; cout << "\n\n"; cout << "\n display them using next member function " << "\n -----------------------------------------"; string element; coll.begin(); cout << "\n " << coll.value(); while(coll.next(element)) cout << "\n " << element; cout << "\n\n"; cout << "\n delete a miss-spelled (I think) item " << "\n --------------------------------------"; coll.deleteElem(++(coll.begin())); for(it=coll.begin(); it!=coll.end(); it++) cout << "\n " << *it; cout << "\n\n"; // cout << "\n measure the size of some possible class members " << "\n -------------------------------------------------"; cout.setf(ios::adjustfield,ios::left); cout << "\n " << setw(30) << "sizeof(collection) = " << sizeof(collection); cout << "\n " << setw(30) << "sizeof(string) = " << sizeof(string); cout << "\n " << setw(30) << "sizeof(list) = " << sizeof(list); cout << "\n " << setw(30) << "sizeof(map) = " << sizeof(map); cout << "\n\n"; } #endif