Queue Overview
- A second standard data type is a queue
- The queue is a homogenious collection of data.
- It maintains data in the order received
- It is charactarized by access
- First in First Out (FIFO)
- Or last in last out.
- There are several basic operations
- Enqueue adds an item to the "tail" or end of the queue
- Dequeue removes and item from the front of a queue
- This should produce an error if the queue is empty
- Some implementations this returns the front item.
- Front returns the front item on the queue without removing it.
- This should produce an error if the queue is empty
- Size returns the number of elements in the queue.
- IsEmpty returs true if the queue is empty.
- IsFull returns true if the queue is full.
- Again there are two common implementations.
- Both maitain a front pointer to the item at the front of the queue
- And a rear pointer to the item at the back of the queue.
- The array based implementation
- This is more difficult as you need to "circle" through the array.
- The list based implementation is straight forward
- The head pointer is the front of the queue
- The last item in the queue is the rear