csc241.samples.Queue
Class fixedQueue

java.lang.Object
  |
  +--csc241.samples.Queue.fixedQueue
All Implemented Interfaces:
Queue

public class fixedQueue
extends java.lang.Object
implements Queue

~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

fixedQueue

public fixedQueue(int size)
construct a fixedQueue
size - the # of cells needed

Method Detail

empty

public boolean empty()
return true if queue is empty, otherwise, return false

Specified by:
empty in interface Queue

full

public boolean full()
return true if queue is full, otherwise, return false

Specified by:
full in interface Queue

enqueue

public void enqueue(java.lang.Object x)
             throws queueException
add an element to the back of the queue.
x - the Object to be added

Specified by:
enqueue in interface Queue
Throws:
- - Exception of queue is full.
queueException

dequeue

public void dequeue()
             throws queueException
remove an element from the front of the queue.

Specified by:
dequeue in interface Queue
Throws:
- - Exception if queue is empty.
queueException

peek

public java.lang.Object peek()
return value - the object in front of the queue; null if queue is empty.

Specified by:
peek in interface Queue