Problem

Consider the following situation. You create a list, and then you add 10 items to it. Yo...

Consider the following situation. You create a list, and then you add 10 items to it. You get an iterator to the list and call next twice to advance it. You remove the first five items from the list, using the list’s remove method. You then call the iterator’s remove method, expecting to remove the item last returned by the method next. However, this entry has already been removed from the list. Changing the state of the list while using the iterator, as you have done here, may result in unpredictable behavior of the iterator.

Modify the interface Iterator so that the methods will throw the exception StateChangedException if the state of the list is changed after the iterator was created but before the method is called. Modify the implementation of LinkedListWithIterator that Project 1 describes to accommodate the changes to Iterator.

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 15
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