UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.collection
Class QueueFixedSize

java.lang.Object
  |
  +--edu.berkeley.guir.lib.collection.QueueFixedSize
All Implemented Interfaces:
Queue

public class QueueFixedSize
extends Object
implements Queue

A statically sized queue that does not resize itself.

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Nov 25 1997, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.1.4
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
(jasonh@cs.berkeley.edu)

Constructor Summary
QueueFixedSize(int iQueueCapacity)
          Constructor to set the capacity of the Queue.
 
Method Summary
 int capacity()
          Get the current maximum capacity of the queue.
 void clear()
          Clears out all elements in the Queue.
 Object dequeue()
          Remove and return the first element in the queue.
 void enqueue(Object obj)
          Add an element to the end of the queue.
 boolean isEmpty()
          Checks if the queue is empty.
 boolean isFull()
          Check if the queue is full.
 Object peek()
          Return the first element in the queue without removing it.
 int size()
          Gets the size of the queue (the current number of elements in the queue).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueueFixedSize

public QueueFixedSize(int iQueueCapacity)
Constructor to set the capacity of the Queue.
Parameters:
iQueueCapacity - is the Capacity of the queue to set to. The capacity must be greater than 0.
Method Detail

clear

public void clear()
Description copied from interface: Queue
Clears out all elements in the Queue.
Specified by:
clear in interface Queue

enqueue

public void enqueue(Object obj)
             throws FullException
Description copied from interface: Queue
Add an element to the end of the queue.
Specified by:
enqueue in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Parameters:
o - is the Object to add to the queue.
Throws:
QueueFullException - if the queue is full

dequeue

public Object dequeue()
               throws EmptyException
Description copied from interface: Queue
Remove and return the first element in the queue.
Specified by:
dequeue in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Returns:
An object representing the first element in the queue
Throws:
QueueEmptyException - if the Queue is empty

peek

public Object peek()
Description copied from interface: Queue
Return the first element in the queue without removing it.
Specified by:
peek in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Returns:
An object representing the first element in the queue, null if empty.

isEmpty

public boolean isEmpty()
Description copied from interface: Queue
Checks if the queue is empty.
Specified by:
isEmpty in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Returns:
true if the queue is empty, false otherwise

isFull

public boolean isFull()
Description copied from interface: Queue
Check if the queue is full.
Specified by:
isFull in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Returns:
Returns the status of the queue (full or not).

capacity

public int capacity()
Description copied from interface: Queue
Get the current maximum capacity of the queue.
Specified by:
capacity in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Returns:
an int representing the current maximum capacity of the queue.

size

public int size()
Description copied from interface: Queue
Gets the size of the queue (the current number of elements in the queue).
Specified by:
size in interface Queue
Following copied from interface: edu.berkeley.guir.lib.collection.Queue
Returns:
An int representing the current number of elements in the queue.

toString

public String toString()
Overrides:
toString in class Object

Copyright Information