|
A first-in-first-out queue (FIFO queue) is an abstract data type. Each queue object holds a sequence of values. The type and operations are as follows.
Type Queue
When an object of type Queue is created it starts out as an empty queue. Items can be added and removed by the operations below. |
isEmpty(q)
Return true if queue q is empty, false if not. |
insertAtEnd(x, q)
Add x to the end of q. |
removeFirst(q)
Remove the first item from q and return it. If q is empty, return −1. |
peek(q)
Return the first item in q without modifying q. If q is empty, return −1. |
Although a queue can contain any type of item, we will only look at queues whose items are integers for simplicity.
|