|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvisidia.simulation.evtack.VQueue
public class VQueue
A VQueue object implements a FIFO (First In First Out) list. It can be used
in multi-threads environment since all it's methods are synchronized. The get
(resp. put) method blocks when there is no element to return (resp. when the
queue contains maxSize elements). If the calling thread is interrupted while
it is blocked in these methods, the InterruptedException
is
thrown.
Constructor Summary | |
---|---|
VQueue()
Constructs a queue with default maximum size which is Integer.MAX_VALUE. |
|
VQueue(int maxSize)
Constructs a queue with maximum size maxSize . |
Method Summary | |
---|---|
boolean |
contains(Criterion c)
Returns true if the queue contains one element that matches the criterion c. |
java.lang.Object |
get()
Returns the first element in the queue. |
java.lang.Object |
get(Criterion c)
Returns the first element in the queue that match the criterion c . |
java.util.Vector<java.lang.Object> |
getAllNoWait(Criterion c)
Returns all elements in the queue that match the criterion c . |
int |
getMaxSize()
Returns this queue maximum size. |
java.lang.Object |
getNoWait(Criterion c)
Returns the first element in the queue that matches the criterion c . |
boolean |
isEmpty()
Returns true if the queue is empty. |
void |
notifyAllGet()
Do not use this method if your are not sure about what you are doing. |
void |
purge()
Removes all elements from the queue. |
void |
put(java.lang.Object obj)
Adds one element at the end of the queue. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VQueue()
public VQueue(int maxSize)
maxSize
.
maxSize
- the max sizeMethod Detail |
---|
public java.lang.Object get() throws java.lang.InterruptedException
java.lang.InterruptedException
- the interrupted exceptionpublic java.lang.Object get(Criterion c) throws java.lang.InterruptedException
c
. If the queue does not contain any element that match
the criterion c
, this method blocks until one element matching
c
becomes available.
c
- the criterion
java.lang.InterruptedException
- the interrupted exceptionpublic java.lang.Object getNoWait(Criterion c) throws java.lang.InterruptedException
c
. If the queue does not contains any element that match
the criterion c
, this method returns null.
c
- the criterion
java.lang.InterruptedException
- the interrupted exceptionpublic java.util.Vector<java.lang.Object> getAllNoWait(Criterion c) throws java.lang.InterruptedException
c
.
If the queue does not contain any element that match the criterion
c
, this method returns null.
c
- the criterion
java.lang.InterruptedException
- the interrupted exceptionpublic void put(java.lang.Object obj) throws java.lang.InterruptedException
maxSize
elements this method blocks until one element is
consumed.
obj
- the object
java.lang.InterruptedException
- the interrupted exceptionpublic boolean isEmpty()
public boolean contains(Criterion c)
c
- the criterion
public void purge()
public int getMaxSize()
public void notifyAllGet()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |