|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractQueue
m865.datastructures.QueueLL
This class implements a Queue using a simple Linked List.
Nested Class Summary | |
protected class |
QueueLL.Link
The Linked List is built from a simple forward link. |
class |
QueueLL.QueueLLIterator
An iterator for a QueueLL. |
Field Summary | |
protected QueueLL.Link |
back
This link points to the back of the Linked List. |
protected QueueLL.Link |
front
This link points to the front of the Linked List. |
Fields inherited from class m865.datastructures.AbstractQueue |
hash |
Constructor Summary | |
|
QueueLL()
Constructs a queue which uses a simple Linked List. |
|
QueueLL(java.util.Collection c)
Constructs a queue which is initialized with the objects in the specified collection |
protected |
QueueLL(int hash,
QueueLL.Link front,
QueueLL.Link back)
Constructs a queue with a specified hash code and a clone of the specified ArrayList. |
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. |
java.lang.Object |
dequeue()
Removes and returns the object at the beginning of the queue. |
void |
enqueue(java.lang.Object obj)
Appends an object to the end of the queue. |
boolean |
isEmpty()
Determines whether the queue is empty. |
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 QueueLL class to insure that the elementary functions are correct. |
java.lang.Object |
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, remove, removeAll, retainAll, toArray, toArray, updateHashCode |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected QueueLL.Link front
protected QueueLL.Link back
Constructor Detail |
public QueueLL()
public QueueLL(java.util.Collection c)
c
- the collection of objects to be initially enqueued
onto this queue.protected QueueLL(int hash, QueueLL.Link front, QueueLL.Link back)
hash
- the hash codefront
- the link to the front of the linked list queue.back
- the link to the back of the linked list queue.Method Detail |
public void enqueue(java.lang.Object obj)
enqueue
in class AbstractQueue
obj
- the object to be appended to the end of the queue.public java.lang.Object dequeue()
dequeue
in class AbstractQueue
public java.lang.Object peek()
peek
in class AbstractQueue
public void clear()
public java.lang.Object clone()
public boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in class AbstractQueue
public java.util.Iterator iterator()
public int size()
public java.lang.String toString()
toString
in class AbstractQueue
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 |