CHAPTER 3 COLLECTIONS Abstract Data Types. 2 A data type consists of a set of values or elements, called its domain, and a set of operators acting on.
Published byModified over 5 years ago
Presentation on theme: "CHAPTER 3 COLLECTIONS Abstract Data Types. 2 A data type consists of a set of values or elements, called its domain, and a set of operators acting on."— Presentation transcript:
2 A data type consists of a set of values or elements, called its domain, and a set of operators acting on that domain. Abstract Data Type: A set of data values and associated operations that are precisely specified independent of any particular implementation
3 ADT specification ADT specification is language independent. It consists of specifying the data values and the operations
4 ADT design and implementation Based on encapsulation : The user of the ADT should not be concerned with how the values are represented, and how the operations are implemented The user should be concerned only with how to create and use objects of a particular ADT ADT interface description
5 Interfaces The interface to an ADT tells the user how to use the ADT The interface says what the allowed operations are. The interface says nothing about how the operations are implemented. The class that implements the interface provides the bodies of the methods
6 Collections A collection is an object that gathers and organizes other objects (elements). Some fundamental collections are: stack, queue, list, tree, graph, etc. Collections can be broadly categorized as linear (organizes the elements in a straight line) or nonlinear
8 Element Organization The elements within a collection are usually organized based on: the order in which they were added to a collection, some inherent relationship among the elements themselves
9 Collections as ADTs Define the collection conceptually as a set of values and a set of operations Define the interface to the ADT Design and implement the corresponding Java class that will contain the data representation and will implement the interface
10 Basic operations for collections add and remove elements determine if the collection is empty determine the collection's size iterators, to process each element in the collection operations that interact with other collections
11 Issues How does the collection operate conceptually? How do we formally define its interface? What kinds of problems does it help us solve? What ways might we implement it? What are the benefits and costs of each implementation?