#include #include #include using std::cout; using std::endl; #include "cs2list.h" int main() { // ======================================= // CHECKPOINT 1 // create a list of the sqrt of the first 10 integers cs2list a; for (int i = 0; i < 10; ++i) a.push_back(sqrt(i)); // print out details of the list // // NOTE: including this output will probably lead to valgrind messages // about memory that is "still reachable"... that's ok. /* cout << "a.size() = " << a.size() << " --- should be 10" << endl; cout << "a.front() = " << a.front() << " --- should be 0.0 " << endl; cout << "a.back() = " << a.back() << " --- should be 3.0" << endl; cs2list::iterator itr; cout << "Elements = "; for (itr = a.begin(); itr != a.end(); ++itr) cout << " " << *itr; cout << endl; */ // clear out the list a.clear(); // ======================================= // CHECKPOINT 2 /* // USING STL LIST std::list b; for (int i = 0; i < 5; i++) { b.push_back(i); } // iterate backwards cout << "elements: "; std::list::iterator itr2 = b.end(); while (itr2 != b.begin()) { itr2--; cout << " " << *itr2; } cout << endl; // USING CS2LIST cs2list c; for (int i = 0; i < 5; i++) { c.push_back(i); } // iterate backwards cout << "elements: "; cs2list::iterator itr3 = c.end(); while (itr3 != c.begin()) { itr3--; cout << " " << *itr3; } cout << endl; */ return 0; }