Homework 4, Spinning in Circles.

Short Description:

Implement a doubly linked list circular class.

This assignment is worth 30 points.

Goals

When you finish this homework, you should have:

Formal Description

For the playlist manager of my media player, I would like to employ a doubly linked circular list (DLCL) . This will allow for a very nice "random play" feature where the program can generate a random offset from the current song, either positive or negative, and easily move by that amount to play the next song. Your assignment is to implement this class.

A doubly linked list is a list where each node is linked to both neighbors. In the node structure there are most likely two pointers, a left pointer which points to the node to the left, and a right pointer which points to the node to the right.

The double links make it easy to traverse the list in either direction.

In a circularly linked list the first node is connected to the last node, forming a circle. There is still a head node pointing to the first node in the list, but you can move from the last node in the list to the first node in the list via a link. In a doubly linked circular list, the last node and the head node are fully linked to each other.

For a DLCL with one node, that node will have two pointers pointing the node.

Until we learn to develop templates, we must fix the data type. For this exercise, use std::string as the data type to store in each node.

Until we learn how to deal with exceptions, your class will print an error and return a standard value when the user attempts to perform an illegal operation. Full details are provided below.

You should implement your DLCL in separate source and header files to allow use in multiple program. Please use DListT.h for your header file.

This class should support iterators, but since we don't yet have the ability to implement these, we will maintain an internal "current" pointer. This pointer will allow the user to manipulate and access the data stored in the structure. The user does not have direct access to the current pointer, but must manipulate it through calls to member functions such as Left, Right and Home.

The current pointer (current) should be invalid until data is inserted into the structured. When data is inserted, current should always point to the inserted data. When data is deleted, current should point to a valid node, if possible. Please read the details below.

Your DLCL should support the following methods:

You should also implement any routines needed to create a fully functional class containing dynamic memory. This includes the ability to pass the class by value, do assignment between instances of classes, and avoid memory leaks or other problems.

You should thoroughly tests your DLCL.

Additional Requirements

Required Files

A single tar file containing the source code and makefile for this program.

Submission

Email your tar file as an attachment to dbennett@edinboro.edu. Make sure that the title indicates that this is homework 4 and that your name and section are included in the body of the message.