Collections and Linked Lists

Collections and Linked Lists - Collections and Linked Lists...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 6/11/09 Collections and Linked Lists • This week the focus is on – the concept of a collection – the importance of separating the interface from the implementation – generic types and their use in collection classes – the difference between fixed and dynamic implementations – dynamically linked lists – the Java Collections API 6/11/09 Outline • Introduction to Collections • A Bag Collection • Array Implementation of a Bag • Linked Lists • Linked Implementation of a Bag 6/11/09 Introduction to Collections • We are used to collections of items: stamps, CDs, keys, etc. • A collection is an object that serves as a repository for other objects • A collection provides services to add, remove, and manage the elements it contains • The underlying data structure used to implement the collection is independent of the operations provided 6/11/09 Introduction to Collections • Collections can be separated into two categories – linear: elements are organized in a straight line – nonlinear: elements are organized in something other than a straight line • Organization elements, relative to each other, is usually determined by – the order in which they were added to the collection – some inherent relationship among the elements 6/11/09 Separating Interface from Implementation • An abstract data type (ADT) is a set of data and the particular operations that are allowed on that data • An ADT is considered abstract because the operations you can perform on it are separated from the underlying implementation • A collection – is an abstract data type – defines interface operations through which the 6/11/09 Separating Interface from Implementation • The details of how a collection is implemented to fulfill that definition should be an independent issue • For every collection we examine, we should consider – How does the collection operate, conceptually? – What operations are included in the interface to the collection? – What kinds of problems does the collection help us solve? – How might the collection be implemented? 6/11/09 Separating Interface from Implementation Class that uses the collection Class that implements the collection Interface to collection Services provided by collection that adhere to an interface 6/11/09 Generic Types • Java permits us to define a class based on a generic type • Our defined class will then be able to operate on, store, and manage objects whose type is not specified until the class is instantiated • Example: we can define a Group class that stores and manages a group of objects. • Using polymorphism, we can define Group to store references to the Object class 6/11/09 Generic Types • However, any type of object could then be stored in our Group , resulting in a loss of control • A better approach is to define the Group to store a generic type T (a convention, though we can use any letter) class group<T> { // declarations and code that manages objects of type T } 6/11/09...
View Full Document

This note was uploaded on 06/11/2009 for the course CS 205214 taught by Professor Balasooriya/kouvetakis during the Spring '09 term at ASU.

Page1 / 61

Collections and Linked Lists - Collections and Linked Lists...

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

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