Package org.jboss.util.collection
Class AbstractQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- org.jboss.util.collection.AbstractQueue<E>
-
- Type Parameters:
E- the element type
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,Queue<E>
- Direct Known Subclasses:
ListQueue
public abstract class AbstractQueue<E> extends java.util.AbstractCollection<E> implements Queue<E>
An abstract implementation of a Queue. Sub-classes must provide methods foraddLast(Object)andremoveFirst().- Version:
- $Revision$
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAXIMUM_SIZEDefault maximum queue sizeprotected intmaximumSizeMaximum queue size-
Fields inherited from interface org.jboss.util.collection.Queue
UNLIMITED_MAXIMUM_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractQueue()Initializes the AbstractQueue.protectedAbstractQueue(int maxSize)Initializes the AbstractQueue.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(E obj)Append and object to the underling list.protected abstract booleanaddLast(E obj)Appends the given element to the end of the queuevoidclear()Removes all of the elements from this queueintgetMaximumSize()Get the maximum size of the queue.booleanisEmpty()Check if the queue is empty.booleanisFull()Check if the queue is full.Eremove()Remove and return the first object in the queue.protected abstract EremoveFirst()Remove the first object in the queuevoidsetMaximumSize(int size)Set the maximum size of the queue-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
getMaximumSize
public int getMaximumSize()
Get the maximum size of the queue.- Specified by:
getMaximumSizein interfaceQueue<E>- Returns:
- Maximum queue size or
Queue.UNLIMITED_MAXIMUM_SIZE.
-
setMaximumSize
public void setMaximumSize(int size)
Set the maximum size of the queue- Specified by:
setMaximumSizein interfaceQueue<E>- Parameters:
size- New maximim queue size orQueue.UNLIMITED_MAXIMUM_SIZE.- Throws:
java.lang.IllegalArgumentException- Illegal size.
-
isFull
public boolean isFull()
Check if the queue is full.
-
isEmpty
public boolean isEmpty()
Check if the queue is empty.
-
add
public boolean add(E obj) throws FullCollectionException
Append and object to the underling list.
-
remove
public E remove() throws EmptyCollectionException
Remove and return the first object in the queue.- Specified by:
removein interfaceQueue<E>- Returns:
- Dequeued object.
- Throws:
EmptyCollectionException- The queue is empty.
-
clear
public void clear()
Removes all of the elements from this queue
-
addLast
protected abstract boolean addLast(E obj)
Appends the given element to the end of the queue- Parameters:
obj- Object to append- Returns:
- Per Collection.add(), we return a boolean to indicate if the object modified the collection.
-
removeFirst
protected abstract E removeFirst()
Remove the first object in the queue- Returns:
- First object in the queue
-
-