EAF 7.4 Implementation

com.lutris.util
Class CircularQueue

java.lang.Object
  extended by com.lutris.util.CircularQueue

public class CircularQueue
extends java.lang.Object


Field Summary
protected  int count
          Number of objects currently stored in the queue.
protected  int qSize
          The number of objects in the array (Queue size + 1).
protected  java.lang.Object[] queue
          Array of references to the objects being queued.
protected  int rIndex
          The array index for the next object to be removed from the queue.
protected  int sIndex
          The array index for the next object to be stored in the queue.
 
Constructor Summary
CircularQueue(int s)
          Creates a circular queue of size s (s objects).
 
Method Summary
 java.lang.Object get()
          Removes an object from the queue.
 int getCount()
          Returns the total number of objects stored in the queue.
 boolean isEmpty()
          Checks to see if the queue is empty.
 boolean put(java.lang.Object x)
          Stores an object in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected java.lang.Object[] queue
Array of references to the objects being queued.


sIndex

protected int sIndex
The array index for the next object to be stored in the queue.


rIndex

protected int rIndex
The array index for the next object to be removed from the queue.


count

protected int count
Number of objects currently stored in the queue.


qSize

protected int qSize
The number of objects in the array (Queue size + 1).

Constructor Detail

CircularQueue

public CircularQueue(int s)
Creates a circular queue of size s (s objects).

Parameters:
s - The maximum number of elements to be queued.
Method Detail

put

public boolean put(java.lang.Object x)
            throws java.lang.ArrayIndexOutOfBoundsException
Stores an object in the queue.

Parameters:
x - The object to be stored in the queue.
Returns:
true if successful, false otherwise.
Throws:
java.lang.ArrayIndexOutOfBoundsException

get

public java.lang.Object get()
                     throws java.lang.ArrayIndexOutOfBoundsException
Removes an object from the queue.

Returns:
a reference to the object being retrieved.
Throws:
java.lang.ArrayIndexOutOfBoundsException

getCount

public int getCount()
Returns the total number of objects stored in the queue.

Returns:
The total number of objects in the queue.

isEmpty

public boolean isEmpty()
Checks to see if the queue is empty.

Returns:
true if queue is empty, false otherwise.

EAF 7.4 Implementation