Queues and Operations on it in C

Queues and Operations on it in C
A Queue is an ordered collection of items from which items may be deleted at one end (called the front of the queue) and into which items may be inserted at the other end (the rear of the queue).Queues are first in first out (FIFO) data structures.
Queues are used where the elements are processed in the order in which they arrive-for example the process queue, the print queue.
Operations on a queue:
InitQueue(Queue):
creates an empty queue
Join (Item):
inserts an item to the rear of the queue
Leave(Queue) :
removes an item from the front of the queue
isEmpty(Queue) :
returns true is the queue is empty
Queue overflow:
The condition resulting from trying to add an element onto a full queue.
if(!q.IsFull())
q.Join(item);
Queue underflow:
The condition resulting from trying to remove an element from an empty queue.
if(!q.IsEmpty())
q.Leave(item);

No comments: