ch.elca.dependency.util
Class ArrayQueue

java.lang.Object
  |
  +--ch.elca.dependency.util.ArrayQueue
All Implemented Interfaces:
Queue

public class ArrayQueue
extends java.lang.Object
implements Queue

Implementation of the standard Queue interface.

Version:
1.0-beta
Author:
Christoph Trutmann

Constructor Summary
ArrayQueue()
          Constructor - Initializes the fields.
ArrayQueue(int capacity)
          Constructor - Initializes the fields.
 
Method Summary
 java.lang.Object dequeue()
          Remove and return from the queue the object at the front.
 void enqueue(java.lang.Object o)
          Insert object o at the rear of the queue.
 java.lang.Object front()
          Return, but do not remove, the front object in the queue.
 boolean isEmpty()
          Return a boolean value that indicates whether the queue is empty.
 int size()
          Return the number of objects in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayQueue

public ArrayQueue()
Constructor - Initializes the fields. The capacity is defined as a constant.


ArrayQueue

public ArrayQueue(int capacity)
Constructor - Initializes the fields. The capacity is defined as an argument in the constructor.

Parameters:
capacity - an int value
Method Detail

enqueue

public void enqueue(java.lang.Object o)
             throws QueueFullException
Insert object o at the rear of the queue.

Specified by:
enqueue in interface Queue
Parameters:
o - Object to be inserted at the rear of the queue.
Throws:
QueueFullException - If the queue is full.

dequeue

public java.lang.Object dequeue()
                         throws QueueEmptyException
Remove and return from the queue the object at the front.

Specified by:
dequeue in interface Queue
Returns:
Object removed from the front of the queue.
Throws:
QueueEmptyException - If the queue is empty.

size

public int size()
Return the number of objects in the queue.

Specified by:
size in interface Queue
Returns:
Number of objects in the queue.

isEmpty

public boolean isEmpty()
Return a boolean value that indicates whether the queue is empty.

Specified by:
isEmpty in interface Queue
Returns:
True if the queue is empty.

front

public java.lang.Object front()
                       throws QueueEmptyException
Return, but do not remove, the front object in the queue. An error occurs if the qeue is empty.

Specified by:
front in interface Queue
Returns:
Object in front of the queue.
Throws:
QueueEmptyException - If the queue is empty.


Copyright © 2003 ELCA Informatique SA. All Rights Reserved.