|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectscranton.queue.QueueViaArrayCirc
Implements the Queue interface via compositon using an array (wraparound).
| Field Summary | |
protected java.lang.Object[] |
actual
The array that contains the objects in the queue. |
protected int |
front
The index to the array location that contains the front. |
protected int |
qSize
The actual size of the queue |
| Constructor Summary | |
|
QueueViaArrayCirc()
Constructs an empty queue |
(package private) |
QueueViaArrayCirc(int size)
Constructs an empty queue of the indicated size. |
| Method Summary | |
java.lang.Object |
dequeue()
Decrease the size of the queue by one by removing and returning reference to the object that was at the front of the queue. |
private java.lang.Object[] |
doubler(java.lang.Object[] oldArray)
Method doubler doubles the sixe of the array containing the queue and copies the queue into the new array. |
void |
enqueue(java.lang.Object item)
Increase the size of the queue by one by placing item as the rear of the queue. |
Queue |
factory()
|
java.lang.Object |
frontOf()
Queue does not change, returns the reference to the front object in the queue. |
boolean |
isEmpty()
Queue does not change, returns true iff the queue is empty. |
java.lang.String |
toString()
Returns a string representation of the queue. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.lang.Object[] actual
protected int front
protected int qSize
| Constructor Detail |
public QueueViaArrayCirc()
QueueViaArrayCirc(int size)
size - Establishes the initial size of the array actual| Method Detail |
public boolean isEmpty()
Queue
|
Q'=Q Return Q==() |
isEmpty in interface QueueQueue.isEmpty()public java.lang.Object frontOf()
Queue
|
Q!=() Q'=Q Return a0 |
frontOf in interface QueueQueue.frontOf()public void enqueue(java.lang.Object item)
Queue
| Q'=(Q, obj) |
enqueue in interface Queueitem - The new rear of the queueQueue.enqueue(java.lang.Object)public java.lang.Object dequeue()
Queue
|
Q!=() Q = (a0, Q') Return: a0 |
dequeue in interface QueueQueue.dequeue()private java.lang.Object[] doubler(java.lang.Object[] oldArray)
oldArray - The (filled) array containing the stack's objects
public java.lang.String toString()
Queue
toString in interface Queuepublic Queue factory()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||