edu.trinity.cs.bmassing.adt1
Class FixedArrayQueue<E>

java.lang.Object
  extended by edu.trinity.cs.bmassing.adt1.FixedArrayQueue<E>
All Implemented Interfaces:
SimpleQueue<E>

public class FixedArrayQueue<E>
extends java.lang.Object
implements SimpleQueue<E>

Class for fixed-size array-based queues.


Constructor Summary
FixedArrayQueue(int size)
          Constructs a new FixedArrayQueue of the specified size.
 
Method Summary
 E dequeue()
          Removes an element from the queue.
 boolean empty()
          Tells whether queue is empty.
 void enqueue(E x)
          Adds an element to the end of the queue.
 E front()
          Gets the front element of the queue (but does not remove it).
static void main(java.lang.String[] args)
          Performs minimal testing/demo of other functions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedArrayQueue

public FixedArrayQueue(int size)
Constructs a new FixedArrayQueue of the specified size.

Parameters:
size - maximum number of elements
Method Detail

empty

public boolean empty()
Tells whether queue is empty.

Specified by:
empty in interface SimpleQueue<E>
Returns:
true if queue is empty, false otherwise

enqueue

public void enqueue(E x)
             throws QueueFullException
Adds an element to the end of the queue.

Specified by:
enqueue in interface SimpleQueue<E>
Parameters:
x - element to add
Throws:
QueueFullException - if queue is already full

dequeue

public E dequeue()
          throws QueueEmptyException
Removes an element from the queue.

Specified by:
dequeue in interface SimpleQueue<E>
Returns:
(former) front element of queue
Throws:
QueueEmptyException - if queue is empty

front

public E front()
        throws QueueEmptyException
Gets the front element of the queue (but does not remove it).

Specified by:
front in interface SimpleQueue<E>
Returns:
front element of queue
Throws:
QueueEmptyException - if queue is empty

main

public static void main(java.lang.String[] args)
Performs minimal testing/demo of other functions.

Parameters:
args - command-line arguments (unused)