org.jboss.util.collection
Class ListQueue

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byorg.jboss.util.collection.AbstractQueue (src) 
          extended byorg.jboss.util.collection.ListQueue
All Implemented Interfaces:
java.util.Collection, Queue (src)

public class ListQueue
extends AbstractQueue (src)

A ListQueue implements a first-in, first-out container using a List as a data structure.


Field Summary
protected  java.util.List list
          List container
 
Fields inherited from class org.jboss.util.collection.AbstractQueue (src)
DEFAULT_MAXIMUM_SIZE, maximumSize
 
Fields inherited from interface org.jboss.util.collection.Queue (src)
UNLIMITED_MAXIMUM_SIZE
 
Constructor Summary
ListQueue()
          Construct a new unconstrained ListQueue using a LinkedList for a data-structure.
ListQueue(int maxSize)
          Construct a new constrained ListQueue using a LinkedList for a data-structure.
ListQueue(java.util.List list)
          Construct a new unconstrained ListQueue.
ListQueue(java.util.List list, int maxSize)
          Construct a new constrained ListQueue.
 
Method Summary
protected  boolean addLast(java.lang.Object obj)
          Appends the given element to the end of this list.
 java.lang.Object getBack()
          Get the object at the back of the queue.
 java.lang.Object getFront()
          Get the object at the front of the queue.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this list in proper sequence.
protected  java.lang.Object removeFirst()
          Remove the first object in the queue.
 java.util.Iterator reverseIterator()
          Returns an iterator over the elements in this list in reverse sequence.
 int size()
          Get the size of the queue.
 java.lang.String toString()
          Return a String representation of this queue.
 
Methods inherited from class org.jboss.util.collection.AbstractQueue (src)
add, clear, getMaximumSize, isEmpty, isFull, remove, setMaximumSize
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, contains, containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

list

protected final java.util.List list
List container

Constructor Detail

ListQueue

public ListQueue(java.util.List list,
                 int maxSize)
Construct a new constrained ListQueue.

Parameters:
list - The list which will be used to store queued objects.
maxSize - The maximum size of the queue.
Throws:
java.lang.IllegalArgumentException - List is null.

ListQueue

public ListQueue(int maxSize)
Construct a new constrained ListQueue using a LinkedList for a data-structure.

Parameters:
maxSize - The maximum size of the queue.

ListQueue

public ListQueue(java.util.List list)
Construct a new unconstrained ListQueue.

Parameters:
list - The list which will be used to store queued objects.
Throws:
java.lang.IllegalArgumentException - List is null

ListQueue

public ListQueue()
Construct a new unconstrained ListQueue using a LinkedList for a data-structure.

Method Detail

addLast

protected boolean addLast(java.lang.Object obj)
Appends the given element to the end of this list.

Specified by:
addLast in class AbstractQueue (src)
Parameters:
obj - Object to append.
Returns:
Per Collection.add(), we return a boolean to indicate if the object modified the collection.

removeFirst

protected java.lang.Object removeFirst()
Remove the first object in the queue.

Specified by:
removeFirst in class AbstractQueue (src)
Returns:
First object in the queue.

size

public int size()
Get the size of the queue.

Returns:
The number of elements in the queue.

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this list in proper sequence.

Returns:
An iterator over the elements in this list in proper sequence.

getFront

public java.lang.Object getFront()
                          throws EmptyCollectionException (src) 
Get the object at the front of the queue.

Returns:
Object at the front of the queue.
Throws:
EmptyCollectionException (src) - The queue is empty.

getBack

public java.lang.Object getBack()
                         throws EmptyCollectionException (src) 
Get the object at the back of the queue.

Returns:
Object at the back of the queue.
Throws:
EmptyCollectionException (src) - The queue is empty.

reverseIterator

public java.util.Iterator reverseIterator()
Returns an iterator over the elements in this list in reverse sequence.

Returns:
An iterator over the elements in this list in reverse sequence.

toString

public java.lang.String toString()
Return a String representation of this queue.

Returns:
String