|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractQueue<T>
m865.datastructures.QueueCL<T>
public class QueueCL<T>
This class implements a Queue using a circular list embedded in a dynamic array Version 3.0 incorporates generics
Nested Class Summary | |
---|---|
class |
QueueCL.QueueCLIterator<T>
The iterator that will walk through the elements of this queue from front to back. |
Field Summary | |
---|---|
protected static int |
DEFAULT_CAPACITY
The default capacity of the dynamic array. |
protected int |
head
The index that points to the front of the queue. |
protected T[] |
myArray
The dynamic array. |
protected int |
size
The size of the queue. |
Fields inherited from class m865.datastructures.AbstractQueue |
---|
hash |
Constructor Summary | |
---|---|
|
QueueCL()
Constructs a queue whose dynamic array has the default initial capacity. |
|
QueueCL(java.util.Collection<? extends T> c)
Constructs a queue which is initialized with the objects in the specified collection |
|
QueueCL(int capacity)
Constructs a queue whose dynamic array has a specified initial size. |
protected |
QueueCL(int hash,
int head,
int size,
T[] circularList)
Constructs a queue with a specified hash code and a clone of the array containing the circular list. |
Method Summary | |
---|---|
void |
clear()
Removes all the objects from this queue. |
java.lang.Object |
clone()
The Cloneable Interface indicates that the clone method, which is inherited from Object, is implemented so that a true clone (a true and independent copy) of the object is returned. |
T |
dequeue()
Removes and returns the object at the beginning of the queue. |
void |
enqueue(T x)
Appends a type T object to the end of the queue. |
java.util.Iterator |
iterator()
A factory method which returns an Iterator to the collection in this queue. |
static void |
main(java.lang.String[] args)
This main method tests the QueueCL class to insure that the elementary functions are correct. |
T |
peek()
Returns the object at the beginning of the queue. |
int |
size()
Determines the size of this queue. |
java.lang.String |
toString()
List the objects in the queue |
Methods inherited from class m865.datastructures.AbstractQueue |
---|
add, addAll, contains, containsAll, downdateHashCode, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray, updateHashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_CAPACITY
protected T[] myArray
protected int head
protected int size
Constructor Detail |
---|
public QueueCL(int capacity)
capacity
- the initial size of the dynamic array.public QueueCL()
public QueueCL(java.util.Collection<? extends T> c)
c
- the collection of objects to be initially enqueued
onto this queue.protected QueueCL(int hash, int head, int size, T[] circularList)
hash
- the hash code.head
- the index to the front of the queue.size
- the size of the queue.circularList
- the array that contains the circular listMethod Detail |
---|
public void enqueue(T x)
enqueue
in class AbstractQueue<T>
x
- the object to be appended to the end of the queue.public T dequeue()
dequeue
in class AbstractQueue<T>
public T peek()
peek
in class AbstractQueue<T>
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.util.Iterator iterator()
public int size()
public java.lang.String toString()
toString
in class AbstractQueue<T>
public static void main(java.lang.String[] args)
args
- optional command line arguments which will be ignored.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |