queue.h
Type | |
This type defines the abstract type for a queue. | |
Functions | |
Allocates and returns an empty queue. | |
Frees the storage associated with the specified queue. | |
Adds an element to the end of the queue. | |
Removes the data value at the head of the queue and returns it to the client. | |
Returns the data value at the head of the queue without removing it. | |
Tests whether the queue is empty. | |
Returns the number of elements in the queue. | |
Removes all elements from the queue. | |
Creates a copy of the queue. |
typedef struct QueueCDT *Queue;
Queue newQueue(void);
Usage:
queue = newQueue();
void freeQueue(Queue queue);
Usage:
freeQueue(queue);
void enqueue(Queue queue, void *element);
Usage:
enqueue(queue, element);
void *dequeue(Queue queue);
dequeue
calls
error
with an appropriate message.
Usage:
element = dequeue(queue);
void *peek(Queue queue);
peek
calls error
with
an appropriate message.
Usage:
element = peek(queue);
bool isEmpty(Queue queue);
Usage:
if (isEmpty(queue)) . . .
int size(Queue queue);
Usage:
n = size(queue);
void clear(Queue queue);
Usage:
clear(queue);
Queue clone(Queue queue);
clone
function copies
only the first level of the structure and does not copy the individual
elements.
Usage:
newqueue = clone(queue);