/* * polylist.cpp * * Created on: 21.11.2013 * Author: trifon */ #include "push_pop_list.cpp" #include "slist.cpp" void testPushPopList() { PushPopIntList ppil; ppil.toEnd(new PushPopQueue); ppil.toEnd(new PushPopStack); ppil.toEnd(new PushPopStack); ppil.toEnd(new PushPopQueue); for(PushPopIntList::I it = ppil.begin(); it; ++it) { for(int i = 1; i <= 5; i++) (*it)->push(i); } for(int i = 1; i <= 5; i++) { for(PushPopIntList::I it = ppil.begin(); it; ++it) { int x; (*it)->pop(x); cout << x << ' '; } cout << endl; } for(PushPopIntList::I it = ppil.begin(); it; ++it) delete *it; cout << "Alive!\n"; } void testSList() { SList l; l.toEnd(new SInteger(1)); SList* pl = new SList; pl->toEnd(new SInteger(2)); pl->toEnd(new SInteger(3)); l.toEnd(pl); pl = new SList; pl->toEnd(new SInteger(4)); SList* pll = new SList; pll->toEnd(new SInteger(5)); pl->toEnd(pll); l.toEnd(pl); pl = new SList; pl->toEnd(new SInteger(6)); l.toEnd(pl); l.print(); LinkedList il; l.collectNumbers(il); cout << il; } int main() { // testPushPopList(); testSList(); return 0; }