jdsl.simple.api
Interface Queue

All Known Implementing Classes:
LinkedQueue, ArrayQueue

public abstract interface Queue

Interface for a queue.

A queue is a collection of elements that are inserted and removed according to the first-in first-out principle.

Author:
Michael T. Goodrich, Natasha Gelfand, Mark Handy, Roberto Tamassia
See Also:
QueueEmptyException, Stack, Deque

Method Summary
 java.lang.Object dequeue()
          Remove the element at the front.
 void enqueue(java.lang.Object element)
          Insert an element at the rear.
 java.lang.Object front()
          Inspect the element at the front, without removing it or otherwise changing the queue.
 boolean isEmpty()
          Return true if and only if the queue is empty.
 int size()
          Return the number of elements.
 

Method Detail

size

public int size()
Return the number of elements.
Returns:
number of elements in the queue.

isEmpty

public boolean isEmpty()
Return true if and only if the queue is empty.
Returns:
true if the queue is empty, false otherwise.

front

public java.lang.Object front()
                       throws QueueEmptyException
Inspect the element at the front, without removing it or otherwise changing the queue.
Returns:
element at the front of the queue
Throws:
QueueEmptyException - if the queue is empty

enqueue

public void enqueue(java.lang.Object element)
Insert an element at the rear.
Parameters:
element - new element to be inserted.

dequeue

public java.lang.Object dequeue()
                         throws QueueEmptyException
Remove the element at the front.
Returns:
element removed.
Throws:
QueueEmptyException -