



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Out: 10/ Due: 11/10 by 11:59 PM
Arrays are a rather primitive construct with limited functionality. An array list provide greater functionality. Like an array, it is a collection of homoge- neous data but it, additionally, offers two significant conveniences:
In Lecture # 15, we introduced a strategy for implementing a parameterized stack ADT that uses one external pointer (head ) and a singly-linked list. Your task in this project is to implement a parameterized ArrayList ADT using a singly-linked, circularly linked list similar to the stack implementation we discussed in that lecture. There is only one external pointer which points to the rear of the array list and the node at the rear has a pointer to the node at the front of the array list. The rear pointer is used in inserting and deleting items. Be very careful when de-allocating memory to avoid memory leaks. Do not leave inaccessible memory or dangling pointers. Free up memory that is not being used. By now you should have enough practice with pointer assignments. This project will test your ability to correctly move pointers around.
Here are basic outline of the parameterized classes that you will need.
... class ArrayListException {
class ArrayList { // member functions ... // implement the destructor as a virtual function; ... private:
. ... Node
class Node { public: //constructor ... private: T data; Node
void add(T element);
void add(int index, T element) throw (ArrayListException);
T& operator[](int index) throw (ArrayListException);
T remove(int index) throw (ArrayListException);
long size() const;
Copy the following files from the class directory: arraylist.cpp, arraylist.h and arraylisttest.cpp. Name your executable file arraylisttest. I have also included arraylisttestexe a working binary version of the code. You may copy this file and run it to have a feel for how I expect your code to work when you are done. You will create your own interface file (arraylist.h), containing the ArrayList class with an inner Node class and an ArrayListException class definitions, and implementation file (arraylist.cpp), containing the member functions of the Node and ArrayList classes. This is going to be more or less along the same lines as the parameterized stack implementation provided in lecture # 15 except that the ArrayList class will be circularly-linked.
Compile your program with your makefile until it works properly. Once you are satisfied that your program properly compiles and it is free of any syntax and/or semantic errors, submit your work. You may submit your work as many times as you wish once the due time has not elapsed. After the due time, any further submission will mean that you get no points for the lab.
@file filename @author your name @date 9999-99- Description: describe what this file does Course: CS1254. Logon ID: cs1254xx Project #: 3 Instructor: Duncan */