The principal goal of this initial assignment is to give me a sense of your general approach to programming and your style of design, development, and coding. I've therefore chosen an exercise that poses no great problems either in conception or execution: implementing queues.
As you know from earlier courses in computer science, queues are mutable data structures that impose a linear ordering on their components and a first-in, first-out discipline on access to those components. The only component of a queue that can be inspected, and the only one from which a stored value can be extracted, is the one that was least recently added to the queue.
The header file /home/stone/courses/software-design/code/queue.h provides an
interface specification for queues. It specifies that a queue is a pointer
struct, but leaves it to the implementer to define the type of
struct, and gives the prototypes for six basic functions:
make_queueto create a new, empty queue;
enqueueto add a value to a queue;
dequeueto remove a value from a non-empty queue and return it;
front_of_queueto inspect the front value of a non-empty queue;
is_empty_queueto determine whether a queue is empty; and
free_queueto deallocate the storage for a queue and its components.
The void-pointer type is used in these prototypes for the values stored in queues, in the expectation that callers cast such values to this type when supplying them as arguments and cast them back again into their original types when receiving them as returned values.
The assignment is to design, write, and test an implementation of queues as
specified in this header file. You must, at a minimum, create a queue.c file in which you define the
struct queue_structure type
and write the bodies of the six prototyped functions. In your
implementation, you may define additional incidental types and functions,
but you should not modify queue.h.
In developing your solution to this exercise, please do not work together or copy program code from anyone else, even with their permission. On this occasion, I'm trying to see how you approach the exercise and to understand your individual style. There will be plenty of opportunities to work collaboratively in this course, and I'll be able to structure those opportunities better if I have a good sense of what your individual strengths and weaknesses are.
To submit your solution to this assignment, make a tarball (that is, create a compressed tape-archive file, in .tgz format) containing your queue.c file and any test programs that you created. If you created a Makefile or any files containing program data, documentation, or test output, include them in the tarball as well, but don't send executables or object files -- I'll recompile them if I need them. Attach the tarball to an e-mail message to email@example.com with the subject line "CSC 323: Programming assignment #0".
This assignment is due on Friday, January 27.