lec0223-lists - Todays announcements: MP3 available, due...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Today’s announcements: MP3 available, due 2/25, 11:59p. Today: Abstract Data Type - List
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Abstract Data Types (an example): ToDo List Groc List top 20 movie List Class List List template<class LIT> class List { public: List(); //~List(); int getSize() const; void insert(int loc, LIT e); void remove(int loc); LIT const & getItem(int loc) const; private: //my little secret }; int main() { List<int> myList; myList.insert(1,4); myList.insert(1,6); myList.insert(1,8); myList.insert(3,0); myList.insert(4,myList.getItem(2)); cout << myList.getSize() << endl; myList.remove(2); cout << myList.getItem(3) << endl; return 0; }
Background image of page 2
ADT List, implementation 1: ToDo List Groc List top 20 movie List Class List List template<class LIT> class List { public: List():size(0){} //~List(); int getSize() const; void insert(int loc, LIT e); void remove(int loc); LIT const & getItem(int loc) const; private: LIT items[8]; int size; }; template<class LIT> int List<LIT>:: getSize () const { return size; } template<class LIT> void List<LIT>:: insert (int loc, LIT e){ if ((size + 1) < 8) {
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

lec0223-lists - Todays announcements: MP3 available, due...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online