The goal here is to modify the ArrayListIterator class in this
implementation of ArrayList
(a version of the implementation in Section 3.4)
so that the class provides for the methods:
Currently, the class provides only for the first three methods, and this
part of the homework asks us to implement all five. I am assuming that
the functionality to be implemented by these methods is clear to you --we
have been talking about iterators for some time now, and ArrayListIterator
is just designed to construct an iterator object for the HWArrayList object.
Implementing the five methods will probably involve rewriting the first three
as well. Feel free to add more data fields to the ArrayListIterator class.
- public boolean hasNext()
- public AnyType next()
- public void remove()
- public boolean hasPrevious()
- public AnyType previous()
If you need clarifications, please talk to me or the TA.
Here, we are required to modify the implementation of HWArrayList and
ArrayListIterator so that when we try to use an iterator's methods
when the corresponding list has been modified after the iterator's creation
either by some other iterator or by the list's own methods, a concurrent
modification exception is thrown. This behavior is very similar to what
happens in the author's implementation of LinkedList in Section 3.5. This
feature is implemented by the list keeping track of the number of
modifications to the list since its creation, and by the iterator keeping
track of its version of this number. We will also discuss this idea in class and in the discussion section.
Please submit the two parts in separate files -- this will help if you got the first right and did not complete the second.