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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

We make the follow<strong>in</strong>g observations about class DList above.<br />

• Object of class DNode, which store Str<strong>in</strong>g elements, are used for all the<br />

nodes of the list, <strong>in</strong>clud<strong>in</strong>g the header <strong>and</strong> trailer sent<strong>in</strong>els.<br />

• We can use class DList for a doubly l<strong>in</strong>ked list of Str<strong>in</strong>g objects only.<br />

To build a l<strong>in</strong>ked list of other types of objects, we can use a generic declaration,<br />

which we discuss <strong>in</strong> Chapter 5.<br />

• Methods getFirst <strong>and</strong> getLast provide direct access to the first <strong>and</strong><br />

last nodes <strong>in</strong> the list.<br />

• Methods getPrev <strong>and</strong> getNext allow to traverse the list.<br />

• Methods hasPrev <strong>and</strong> hasNext detect the boundaries of the list.<br />

• Methods, addFirst <strong>and</strong> addLast add a new node at the beg<strong>in</strong>n<strong>in</strong>g or<br />

end of the list.<br />

• Methods, add Before <strong>and</strong> add After add a new node before or after<br />

an exist<strong>in</strong>g node.<br />

179

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

Saved successfully!

Ooh no, something went wrong!