Class Queue<E>

java.lang.Object
  extended by Queue<E>
Type Parameters:
E - The parameter of the Queue.

public class Queue<E>
extends java.lang.Object

Implements a queue data structure. Elements are added to the end of the queue but removed from the front.

Author:
wollowsk. Created Oct. 12, 2010.

Constructor Summary
Queue()
          Creates a new, empty queue.
 
Method Summary
 E dequeue()
          Removes an element to the queue.
 boolean enqueue(E element)
          Adds an element to the queue.
 boolean isEmpty()
          This method tells whether the queue is empty or not.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Creates a new, empty queue.

Method Detail

enqueue

public boolean enqueue(E element)
Adds an element to the queue.

Parameters:
element - The element to be added.
Returns:
Returns true if the element could be added successfully and false otherwise.

dequeue

public E dequeue()
Removes an element to the queue. This method throws a NoSuchElementException, if an attempt is made to dequeue from an empty queue.

Returns:
Returns the element.
Throws:
Throws - a NoSuchElementException if the queue is empty.

isEmpty

public boolean isEmpty()
This method tells whether the queue is empty or not.

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