06_adt

06_adt - Data Structures - CSCI 102 CS102 C+ Abstract Data...

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

View Full Document Right Arrow Icon
1 Data Structures - CSCI 102 Copyright © William C. Cheng CS102 C++ Abstract Data Types Bill Cheng http://merlot.usc.edu/cs102-s11
Background image of page 1

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

View Full DocumentRight Arrow Icon
Stacks/Queues (Ch 18) Topics to cover 2 Data Structures - CSCI 102 Copyright © William C. Cheng C++ Abstract Data Types Vectors (Ch 22) Linked Lists (Ch 17) Templates (Ch 14)
Background image of page 2
An abstract data type that separates the logical properties from the implementation details (Encapsulation, Information Hiding) What is an ADT? 3 Data Structures - CSCI 102 Copyright © William C. Cheng The List ADT We can define all the types of things we want to do with a List without really specifying how they should be implemented insert, remove, search, etc. The List ADT How does vector work? The C++ vector is a good example
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Data Structures - CSCI 102 Copyright © William C. Cheng CS102 Extra Slides Bill Cheng http://merlot.usc.edu/cs102-s11
Background image of page 4
5 Data Structures - CSCI 102 Copyright © William C. Cheng adt_list.h /* * 1) Write an abstract data type (ADT) representation of a * List of integers. This class is purely an interface * (it has no actual implementation details). * 2) The contains() method checks to see if an integer is * stored in the list. * 3) The push_front() method pushes an integer into the * front of the list (prepends). * 4) The push_back() method appends an integer to the * front of the list. * 5) The at() method returns a reference to the integer * at the given index. * 6) The erase() method erases the integer at the given index. * 7) The empty() method returns true if the list is empty. * 8) The size() method returns the number of elements in * the list. * 9) The print() method prints all the integers in the list. * to cout. */
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Data Structures - CSCI 102 Copyright © William C. Cheng adt_list.h #ifndef ADT_LIST_H_ #define ADT_LIST_H_ class List { public: virtual bool contains(int val) const = 0; virtual void push_front(int val) = 0; virtual void push_back(int val) = 0;
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

06_adt - Data Structures - CSCI 102 CS102 C+ Abstract Data...

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

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