Problem

Implement a generic doubly linked list implementation called DoubleRefBasedList that imple...

Implement a generic doubly linked list implementation called DoubleRefBasedList that implements the generic Listlnterface presented in dais chapter. In addition, create an iterator called DListlterator for the DoubleRefBasedList class. To make the implementation of DListlterator more efficient, you need to have access to the underlying doubly linked list in DoubleRefBasedList. The easiest way to accomplish diis is to move the iterator class inside the list class. This inner class is then a member of the DoubleRefBasedList class and will have access to all of the members of that class. So The DoubleRefBasedList class with an inner DListlterator class will be structured as follows:

public class DoubleRefBasedListimplements Listlnterface{

private DNodehead;

// Assume Dnode has been defined as a node class with both

// a next and previous reference. It is used to implement

// the doubly linked list.

// Class members for Listlnterface implementation appear here.

// Inner class DListlterator

private class DListlterator

implements java.util.ListIterator{

private DNode cursor = head;

// Class members for Listlterator implementation appear here.

// This inner class has access to members of the outer class.

} // end DListlterator

public java.util.ListIteratorlistlterator() {

return new DListlterator();

} // end listlterator

} // end DoubleRefBasedList

The cursor declaration is shown to demonstrate how members of the outer class can be accessed from the inner class. When a call is made to the DoubleRef BasedList method listlterator, the cursor will be initialized to reference the first node in the list.

Also write a test class diat tests that the operations for both the DoubleRef BasedList class and the DListlterator class are working properly.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 9
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT