|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--csc241.samples.Queue.dynamicQueue
~mohammad/public_html/classes/csc241/Queue/dynamicQueue.java This version implements Queue using a linked list. The concept here is unlike anything you have done before. It is important to understand object refernences. A Queue has two components, 'front_' reference to the node holding the element in front and 'back_' reference to the node holding the element in the back. We remove from front and add to the back in our enqueue and dequeue, resepectively. Just like fixedQueue, all methods have implementation.
Constructor Summary | |
dynamicQueue()
construct a dynamicQueue |
Method Summary | |
void |
dequeue()
remove an element from the front of the queue. |
boolean |
empty()
return true if queue is empty, otherwise, return false |
void |
enqueue(java.lang.Object x)
add an element to the back of the queue. |
boolean |
full()
return true if queue is full, otherwise, return false |
java.lang.Object |
peek()
return value - the object in front of the queue; null if queue is empty. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public dynamicQueue()
Method Detail |
public boolean empty()
empty
in interface Queue
public boolean full()
full
in interface Queue
public void enqueue(java.lang.Object x) throws queueException
enqueue
in interface Queue
-
- Exception if queue is full.
queueException
public void dequeue() throws queueException
dequeue
in interface Queue
-
- Exception if queue is empty.
queueException
public java.lang.Object peek()
peek
in interface Queue
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |