datastructures

net.datastructures
Interface Queue

All Known Implementing Classes:
NodeQueue

public interface Queue

Interface for a queue: 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:
EmptyQueueException

Method Summary
 Object dequeue()
          Removes the element at the front of the queue.
 void enqueue(Object element)
          Inserts an element at the rear of the queue.
 Object front()
          Inspects the element at the front of the queue.
 boolean isEmpty()
          Returns whether the queue is empty.
 int size()
          Returns the number of elements in the queue.
 

Method Detail

size

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

Returns:
number of elements in the queue.

isEmpty

public boolean isEmpty()
Returns whether the queue is empty.

Returns:
true if the queue is empty, false otherwise.

front

public Object front()
             throws EmptyQueueException
Inspects the element at the front of the queue.

Returns:
element at the front of the queue.
Throws:
EmptyQueueException - if the queue is empty.

enqueue

public void enqueue(Object element)
Inserts an element at the rear of the queue.

Parameters:
element - new element to be inserted.

dequeue

public Object dequeue()
               throws EmptyQueueException
Removes the element at the front of the queue.

Returns:
element removed.
Throws:
EmptyQueueException - if the queue is empty.

datastructures