|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.elib.vat.Queue
Safe: A conventional fifo queue in which dequeued items are removed in the same order they were enqueued.
An untyped queue can hold any object (except null). A queue can be created with a dynamic type, in which case, at no extra overhead, enqueue will only enqueue objects of that type (or a subtype, but not null). This check imposes no *extra* overhead, since java always makes us pay for a dynamic type check on array store anyway.
The class Queue itself is no longer thread safe, instead being
optimized for using inside one vat. See the subclass SynchQueue
for a thread-safe variant with a blocking operation.
org.erights.e.elib.vat.Vat
Field Summary | |
private static int |
INITIAL_SIZE
|
private int |
myCurSize
|
private int |
myIn
|
private int |
myMaxSize
|
private int |
myOut
|
private Object[] |
myStuff
|
Constructor Summary | |
Queue()
Enabled: Makes a Queue that can hold any object. |
|
Queue(Class elementType)
Enabled: Makes a Queue that can hold objects of the specified elementType. |
Method Summary | |
void |
enqueue(Object newElement)
Enabled: Add a new element to the queue. |
boolean |
hasMoreElements()
Enabled: Check to see if the queue has more elements. |
Object |
nextElement()
Enabled: Get the least-recently-added element off of the queue. |
Object |
optDequeue()
Enabled: Get the least-recently-added element off of the queue, or null if the queue is currently empty. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Enumeration |
asList, iterate |
Field Detail |
private static final int INITIAL_SIZE
private Object[] myStuff
private int myMaxSize
private int myCurSize
private int myOut
private int myIn
Constructor Detail |
public Queue()
public Queue(Class elementType)
elementType
- may not be a primitive (ie, scalar) type.Method Detail |
public void enqueue(Object newElement)
newElement
- the object to be added to the end of the queue.
NullPointerException
- thrown if newElement is null
ArrayStoreException
- thrown if newElement does not coerce
to the elementType specified in the Queue constructor.public boolean hasMoreElements()
hasMoreElements
in interface Enumeration
public Object nextElement() throws NoSuchElementException
nextElement
in interface Enumeration
NoSuchElementException
public Object optDequeue()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |