|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object
|
+--com.sosnoski.util.GrowableBase
|
+--com.sosnoski.util.queue.QueueBase
Base class for type-specific growable circular queue classes with any type
of values (including primitive types). This class builds on the basic
structure provided by GrowableBase, specializing it for usage
as a queue. See the base class description for details of the
implementation.
Queues based on this class are unsynchronized in order to provide the best possible performance for typical usage scenarios, so explicit synchronization must be implemented by the subclass or the application in cases where they are to be modified in a multithreaded environment.
Subclasses need to implement the abstract methods defined by the base class
for working with the data array, as well as the actual data access methods
(at least the basic add() and remove() methods).
| Field Summary | |
protected int |
m_emptyOffset
Offset for removing next item from queue. |
protected int |
m_fillOffset
Offset for adding next item to queue. |
| Fields inherited from class com.sosnoski.util.GrowableBase |
DEFAULT_SIZE, m_countLimit, m_maximumGrowth |
| Constructor Summary | |
QueueBase(int size,
java.lang.Class type)
Constructor with partial specification. |
|
QueueBase(int size,
int growth,
java.lang.Class type)
Constructor with full specification. |
|
QueueBase(QueueBase base)
Copy (clone) constructor. |
|
| Method Summary | |
protected java.lang.Object |
buildArray(java.lang.Class type)
Constructs and returns a simple array containing the same data as held in this queue. |
void |
clear()
Set the queue to the empty state. |
void |
discard(int count)
Discard items from queue. |
protected int |
getAddIndex()
Make space for adding a value to those in the queue. |
protected int |
getRemoveIndex()
Removes the next item from the queue. |
boolean |
isEmpty()
Check if queue is empty. |
protected void |
resizeCopy(java.lang.Object base,
java.lang.Object grown)
Copy data after array resize. |
int |
size()
Get the number of values currently present in the queue. |
| Methods inherited from class com.sosnoski.util.GrowableBase |
buildArray, discardValues, ensureCapacity, getArray, growArray, setArray |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int m_fillOffset
protected int m_emptyOffset
| Constructor Detail |
public QueueBase(int size,
int growth,
java.lang.Class type)
size - number of elements initially allowed in queuegrowth - maximum size increment for growing queuetype - queue element type
public QueueBase(int size,
java.lang.Class type)
size - number of elements initially allowed in queuetype - queue element typepublic QueueBase(QueueBase base)
from - instance being copied| Method Detail |
protected void resizeCopy(java.lang.Object base,
java.lang.Object grown)
resizeCopy in class GrowableBasebase - original array containing datagrown - resized array for dataprotected int getAddIndex()
protected int getRemoveIndex()
IllegalStateException - on attempt to remove an item from an
empty queuepublic int size()
public boolean isEmpty()
true if queue empty, false if notpublic void clear()
public void discard(int count)
count - number of items to be discardedIllegalStateException - if attempt to discard more items than
present on queueprotected java.lang.Object buildArray(java.lang.Class type)
type - element type for constructed array
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||