23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

deletion is at cursor; A is O(n),L is O(1)<br />

6.4 List ADTs <strong>and</strong> the Collections Framework<br />

In this section, we discuss general list ADTs, which comb<strong>in</strong>e methods of the deque,<br />

array list, <strong>and</strong>/or node list ADTs. Before describ<strong>in</strong>g such ADTs, we mention a larger<br />

context <strong>in</strong> which they exist.<br />

6.4.1 The <strong>Java</strong> Collections Framework<br />

<strong>Java</strong> provides a package of data structure <strong>in</strong>terfaces <strong>and</strong> classes, which together<br />

def<strong>in</strong>e the <strong>Java</strong> Collections Framework. This package, java.util, <strong>in</strong>cludes<br />

versions of several of the data structures discussed <strong>in</strong> this book, some of which we<br />

have already discussed <strong>and</strong> others of which we discuss <strong>in</strong> the rema<strong>in</strong>der of this<br />

book. In particular, the java.util package <strong>in</strong>cludes the follow<strong>in</strong>g <strong>in</strong>terfaces:<br />

Collection:<br />

A general <strong>in</strong>terface for any data structure that conta<strong>in</strong>s a collection of<br />

elements. It extends java.lang.Iterable; hence, it <strong>in</strong>cludes an<br />

iterator() method, which returns an iterator of the elements <strong>in</strong> this<br />

collection.<br />

Iterator:<br />

An <strong>in</strong>terface for the simple iterator ADT.<br />

List:<br />

An <strong>in</strong>terface extend<strong>in</strong>g Collection to <strong>in</strong>clude the array list ADT. It also<br />

<strong>in</strong>cludes a method listIterator for return<strong>in</strong>g a ListIterator object for<br />

this list.<br />

ListIterator:<br />

An iterator <strong>in</strong>terface that provides both forward <strong>and</strong> backward traversal<br />

over a list, as well as cursor-based update methods.<br />

Map:<br />

An <strong>in</strong>terface for mapp<strong>in</strong>g keys to values. This concept <strong>and</strong> <strong>in</strong>terface are<br />

discussed <strong>in</strong> Section 9.1.<br />

Queue:<br />

351

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!