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 int
DEFAULT_MAXIMUM_SIZE
Default maximum queue sizeprotected int
maximumSize
Maximum queue size-
Fields inherited from interface org.jboss.util.collection.Queue
UNLIMITED_MAXIMUM_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractQueue()
Initializes the AbstractQueue.protected
AbstractQueue(int maxSize)
Initializes the AbstractQueue.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
add(E obj)
Append and object to the underling list.protected abstract boolean
addLast(E obj)
Appends the given element to the end of the queuevoid
clear()
Removes all of the elements from this queueint
getMaximumSize()
Get the maximum size of the queue.boolean
isEmpty()
Check if the queue is empty.boolean
isFull()
Check if the queue is full.E
remove()
Remove and return the first object in the queue.protected abstract E
removeFirst()
Remove the first object in the queuevoid
setMaximumSize(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:
getMaximumSize
in 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:
setMaximumSize
in 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:
remove
in 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
-
-