netwar.utils
Class AQueue

java.lang.Object
  |
  +--netwar.utils.AQueue
All Implemented Interfaces:
Queue

public class AQueue
extends java.lang.Object
implements Queue

Array based Queue class

Author:
Kyle Kakligian

Constructor Summary
AQueue()
          Constructs a AQueue
AQueue(int size)
          Constructs a AQueue
 
Method Summary
 void clear()
          Clears the queue.
 java.lang.Object dequeue()
          Dequeues an Object.
 void enqueue(java.lang.Object it)
          Enqueues an Object.
 boolean isEmpty()
          Returns whether or not the queue is empty.
 java.lang.Object peek()
          Peeks at the next Object to dequeue.
 void resize(int newSize)
          Internally resizes the queue to hold at least the given number of items
 void shrink()
          Internally resizes the queue to hold at least the given number of items
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AQueue

public AQueue()
Constructs a AQueue

AQueue

public AQueue(int size)
Constructs a AQueue
Parameters:
size - Default Queue size.
Method Detail

resize

public void resize(int newSize)
Internally resizes the queue to hold at least the given number of items
Specified by:
resize in interface Queue
Parameters:
newSize - Resize the Quesue to hold atleast newSize Objects.

shrink

public void shrink()
Internally resizes the queue to hold at least the given number of items
Specified by:
shrink in interface Queue

clear

public void clear()
Clears the queue.
Specified by:
clear in interface Queue

enqueue

public void enqueue(java.lang.Object it)
Enqueues an Object.
Specified by:
enqueue in interface Queue
Parameters:
it - The Object to enqueue.

dequeue

public java.lang.Object dequeue()
Dequeues an Object.
Specified by:
dequeue in interface Queue
Returns:
The dequeued Object.

peek

public java.lang.Object peek()
Peeks at the next Object to dequeue.
Specified by:
peek in interface Queue
Returns:
The next Object to dequeue.

isEmpty

public boolean isEmpty()
Returns whether or not the queue is empty.
Specified by:
isEmpty in interface Queue
Returns:
true if empty.