|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--csc241.samples.Queue.fixedQueue
~mohammad/public_html/classes/csc241/Queue/fixedQueue.java This version implements Queue using an array. We will use a circular list implementation here. You will notice that there are variables and a constructor added to what was shown in the abstract version. You will also notice that we now have code for full,empty, enqueue, and dequeue, and peek. The constructor and the methods are public.
Constructor Summary | |
fixedQueue(int size)
construct a fixedQueue size - the # of cells needed |
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 fixedQueue(int size)
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 of 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 |