Class Queue<D>

java.lang.Object
  extended by Queue<D>
Type Parameters:
D - The key of the data to store in a queue.

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

A list-based implementation of a queue, i.e. FIFO-buffer, where all methods need constant time.

Author:
Rossmanith

Constructor Summary
Queue()
          Create an empty queue.
 
Method Summary
 D dequeue()
          Returns and removes the element at the front of this queue.
 void enqueue(D x)
          Inserts the given element x at the end of this queue.
 boolean isempty()
          Checks whether the queue is empty.
 int size()
          Returns the number of elements in this queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Create an empty queue.

Method Detail

isempty

public boolean isempty()
Checks whether the queue is empty.

Returns:
true, iff there are no elements stored in this queue.

dequeue

public D dequeue()
Returns and removes the element at the front of this queue. Requires that this queue is non-empty.


enqueue

public void enqueue(D x)
Inserts the given element x at the end of this queue.

Parameters:
x - The element to store in this queue.

size

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