|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractQueue<T>
m865.datastructures.QueueLL<T>
public class QueueLL<T>
This class implements a Queue using a simple Linked List. Version 3.0 incorporates generics
Nested Class Summary | |
---|---|
class |
QueueLL.Link<T>
The Linked List is built from a simple forward link. |
class |
QueueLL.QueueLLIterator<T>
An iterator for a Linked List queue. |
Field Summary | |
---|---|
protected QueueLL.Link<T> |
back
|
protected QueueLL.Link<T> |
front
The queue is implemented with a Linked List The Linked List starts with the link called top. |
protected int |
nItems
|
Fields inherited from class m865.datastructures.AbstractQueue |
---|
hash |
Constructor Summary | |
---|---|
QueueLL()
Constructs a queue which uses a simple Linked List. |
|
QueueLL(java.util.Collection<? extends T> c)
Constructs a queue which is initialized with the objects in the specified collection |
Method Summary | |
---|---|
void |
clear()
Removes all the objects from this queue. |
T |
dequeue()
Removes and returns the object on the top of the queue. |
void |
enqueue(T x)
Enqueues an object to the back of the queue. |
boolean |
isEmpty()
Determines whether the queue is empty. |
java.util.Iterator<T> |
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. |
T |
peek()
Returns the object on the top 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 |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected QueueLL.Link<T> front
protected QueueLL.Link<T> back
protected int nItems
Constructor Detail |
---|
public QueueLL()
public QueueLL(java.util.Collection<? extends T> c)
c
- the collection of objects to be initially pushed
onto this queue.Method Detail |
---|
public void enqueue(T x)
enqueue
in class AbstractQueue<T>
x
- the object to be placed at the back of the queue.public T dequeue()
dequeue
in class AbstractQueue<T>
public T peek()
peek
in class AbstractQueue<T>
public void clear()
public boolean isEmpty()
isEmpty
in interface java.util.Collection<T>
isEmpty
in class AbstractQueue<T>
public java.util.Iterator<T> 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 |