Question: The QUEUE class The header file, queue.h , should look like: #ifndef __QUEUE_INCLUDED__ #define __QUEUE_INCLUDED__ #include typedef struct queue QUEUE; extern QUEUE *newQUEUE(void (*d)(FILE *,void

The QUEUE class

The header file, queue.h, should look like:

 #ifndef __QUEUE_INCLUDED__ #define __QUEUE_INCLUDED__ #include  typedef struct queue QUEUE; extern QUEUE *newQUEUE(void (*d)(FILE *,void *)); extern void enqueue(QUEUE *items,void *value); extern void *dequeue(QUEUE *items); extern void *peekQUEUE(QUEUE *items); extern int sizeQUEUE(QUEUE *items); extern void displayQUEUE(FILE *,QUEUE *items); extern void visualizeQUEUE(FILE *,QUEUE *items); #endif 

The header file contains the function signatures of your public methods while the code module, queue.c, contains their implementations. The only local includes that queue.c should have are queue.h and the header file of the underlying data structure on which the array is based.

Method behavior

Here are some of the behaviors your methods should have. This listing is not exhaustive; you are expected, as a computer scientist, to complete the implementation in the best possible and most logical manner.

newQUEUE - The constructor is passed a function that knows how to display the generic values stored in the queue. That function is stored in a display field of the QUEUE object:

enqueue - The enqueue method runs in constant or amortized constant time. The value to be enqueued is stored in the underlying data structure.

removeQUEUE - The dequeue method runs in constant or amortized constant time. The value to be dequeued is removed in the underlying data structure.

peekQUEUE - The peek method returns the value ready to come off the queue, but leaves the queue unchanged. It runs in constant time.

sizeQUEUE - The size method returns the number of items stored in the queue. It runs in amortized constant time.

displayQUEUE - This display method prints the items stored in the queue. If the integers 5, 6, 2, 9, and 1 are enqueued in the order given, the method would generate this output:

 <5,6,2,9,1> 

with no preceding or following whitespace. An empty queue displays as <>.

visualizeQUEUE - The visualize method simply calls the display method of the data structure upon which the queue is based.

Assertions

Include the following assertions in your methods:

newQUEUE - The memory allocated shall not be zero.

dequeue - The size shall be greater than zero.

peekQUEUE - The size shall be greater than zero.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!