Opus5
Class QueueAsArray
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
|
+--Opus5.QueueAsArray
- All Implemented Interfaces:
- Comparable, Container, Queue
- Direct Known Subclasses:
- DequeAsArray
- public class QueueAsArray
- extends AbstractContainer
- implements Queue
A queue implemented using an array.
- Version:
- $Id: QueueAsArray.java,v 3.2 1998/07/28 02:24:04 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
|
Field Summary |
protected java.lang.Object[] |
array
The array. |
protected int |
head
The position of the head of the queue. |
protected int |
tail
The position of the tail of the queue. |
|
Constructor Summary |
QueueAsArray(int size)
Constructs a QueueAsArray with the specified length. |
|
Method Summary |
void |
accept(Visitor visitor)
Accepts the specified visitor and makes it visit all the objects
in this queue. |
protected int |
compareTo(Comparable arg)
Compares this object with the specified comparable object. |
java.lang.Object |
dequeue()
Dequeus and returns the object at the head of this queue. |
void |
enqueue(java.lang.Object object)
Enqueues the specified object at the tail of this queue. |
Enumeration |
getEnumeration()
Returns an enumeration that enumerates the objects in this queue. |
java.lang.Object |
getHead()
Returns the object at the head of this queue. |
boolean |
isFull()
Tests whether this queue is full. |
void |
purge()
Purges this queue, making it empty. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
array
protected java.lang.Object[] array
- The array.
head
protected int head
- The position of the head of the queue.
tail
protected int tail
- The position of the tail of the queue.
QueueAsArray
public QueueAsArray(int size)
- Constructs a
QueueAsArray with the specified length.
- Parameters:
size - The desired array length.
purge
public void purge()
- Purges this queue, making it empty.
- Specified by:
purge in interface Container
getHead
public java.lang.Object getHead()
- Returns the object at the head of this queue.
- Specified by:
getHead in interface Queue
- Returns:
- The object at the head of this queue.
- Throws:
ContainerEmptyException - If this queue is empty.
enqueue
public void enqueue(java.lang.Object object)
- Enqueues the specified object at the tail of this queue.
- Specified by:
enqueue in interface Queue
- Parameters:
The - object to be enqueued.- Throws:
ContainerFullException - If this queue is full.
dequeue
public java.lang.Object dequeue()
- Dequeus and returns the object at the head of this queue.
- Specified by:
dequeue in interface Queue
- Returns:
- The object at the head of this queue.
- Throws:
ContainerEmptyException - If this queue is empty.
isFull
public boolean isFull()
- Tests whether this queue is full.
- Specified by:
isFull in interface Container- Overrides:
isFull in class AbstractContainer
- Returns:
- True if this queue is full; false otherwise.
accept
public void accept(Visitor visitor)
- Accepts the specified visitor and makes it visit all the objects
in this queue.
- Specified by:
accept in interface Container- Overrides:
accept in class AbstractContainer
- Parameters:
visitor - The visitor to accept.
getEnumeration
public Enumeration getEnumeration()
- Returns an enumeration that enumerates the objects in this queue.
- Specified by:
getEnumeration in interface Container
- Returns:
- an enumeration that enumerates the objects in this queue.
compareTo
protected int compareTo(Comparable arg)
- Compares this object with the specified comparable object.
This method is not implemented.
- Overrides:
compareTo in class AbstractObject
- Parameters:
arg - The comparable object with which this queue is compared.- Throws:
MethodNotImplemented - Always.