// // // // simplified Account list class // // Based on Simplified List Template Class // Described in Chapter 9 of // Data Structures in C++ using the STL // Published by Addison-Wesley, 1997 // Written by Tim Budd, budd@cs.orst.edu // Oregon State University // // // MAR 4/4/00 - Avoided templates because couldn't get // Budd's code to compile under Microsoft Visual Studio v6.0 #ifndef ACCOUNTLISTLIST_H #define ACCOUNTLISTLIST_H #include "Account.h" #include "AccountListLink.h" #include // list class AccountList { public: // constructor and destructor AccountList () : firstLink(0), lastLink(0) { } // MAR 4/4/00 - why does their copy constructor create an empty list? // AccountList (AccountList & x) : firstLink(0), lastLink(0) { } AccountList (AccountList & x); ~ AccountList (); // operations bool empty () { return firstLink == 0; } int size(); Account & back () { return lastLink->value; } Account & front () { return firstLink->value; } void ShowList (); // MAR 4/4/00 - show list in order void push_front(Account &); void push_back(Account &); // no code for this in Budd code void pop_front (); void pop_back (); // no code for this in Budd code AccountLink * begin () { return firstLink; } AccountLink * end () { return lastLink; }// different than in list library!!! void sort (); // no code for this in Budd code void insert (AccountLink *, Account &); void insert_inorder (const Account & toAdd); // insert account in proper sorted order in the list // depends on the list already sorted // wont ask students to do, so haven't written yet void erase (AccountLink * itr) { erase (itr, itr->Next() ); } void erase (AccountLink *, AccountLink *); // second param - stop - points to first element to be not deleted bool remove (const Account & toRemove); // remove a given account from list Account GetNthAccount(int n); // return an account that is nth in the list of accounts AccountLink * GetNthAccountLinkPtr(int n); // return pointer to nth element in list void operator += (AccountList & toAppend); // append right argument to end of left argument // without changing rigth side at all (*copy* it) protected: AccountLink * firstLink; AccountLink * lastLink; }; #endif