Your goals for this lab are to introduce two enhancements to the
OpenDSA AList
class introduced in our textbook:
AList
is instantiated.Iterable
interface, including the remove
operation.Dynamic arrays use the following algorithm to ensure sufficient capacity when new elements are added:
if the current array is full:
* Allocate a new array that is twice as large as the current array.
* Copy all entries from the current array to the new array.
* Replace the current array with the newly allocated array.
The first stage for this lab is to update the OpenDSA AList
class so
that it performs these steps every time append
or insert
is
called. Since the same steps are required for both methods, it would
be appropriate to create a private helper method.
The second stage of the lab involves completing the methods of the
unfinished Iterator
class declared at the bottom of AList
. One
complication involves how removing elements using the iterator should
impact the current position (curr
) of the AList
object. The
expected behavior is as follows:
If this is unclear, I encourage you to read the provided unit tests to get a better understanding of the required behavior.
Submit AList.java
through Autolab.