|
Scribble Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cs101.util.queue.DefaultQueue
Default Queue class. Allows insertion/deletion at either end. Throws EmptyQueueException in some situations, but EmptyQueueException is a subclass of RuntimeException, so you don't have to protect Queue access with try/catch blocks.
Copyright (c) 1998 Massachusetts Institute of Technology
EmptyQueueException
Field Summary |
Fields inherited from interface cs101.util.queue.Queue |
BACK, FRONT |
Constructor Summary | |
DefaultQueue()
Creates a new, empty Queue |
|
DefaultQueue(java.lang.Object obj)
Creates a new Queue contining obj as the only element |
Method Summary | |
java.lang.Object |
dequeue()
Removes and returns the Object at the tail of the queue. |
java.lang.Object |
dequeue(int end)
Removes and returns the Object at the specified end of the queue. |
java.util.Enumeration |
elements()
Returns an Enumeration of the Objects in the queue. |
void |
enqueue(java.lang.Object obj)
Puts obj into the front the queue. |
void |
enqueue(java.lang.Object obj,
int end)
Puts obj into the specified end of the queue. |
boolean |
isEmpty()
Tests whether the queue is empty. |
java.lang.Object |
peek()
Gets the tail object from the queue without removing it. |
java.lang.Object |
peek(int end)
Gets the object from the specified end of the queue without removing it. |
int |
size()
Returns the number of elements in this. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DefaultQueue()
public DefaultQueue(java.lang.Object obj)
Method Detail |
public int size()
size
in interface Queue
public java.lang.Object peek()
peek
in interface Queue
public java.lang.Object peek(int end)
peek
in interface Queue
public void enqueue(java.lang.Object obj)
enqueue
in interface Queue
public void enqueue(java.lang.Object obj, int end)
enqueue
in interface Queue
public java.lang.Object dequeue()
dequeue
in interface Queue
public java.lang.Object dequeue(int end)
dequeue
in interface Queue
public boolean isEmpty()
isEmpty
in interface Queue
public java.util.Enumeration elements()
Note: Do not modify the queue while enumerating--unpredictable behavior may result.
elements
in interface Queue
Enumeration
public java.lang.String toString()
|
Scribble Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |