|
OpMath | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.opmath.mail.CircularQueue
A queue data structure, complete with synchronized access methods. Queue elements are of type
Object.
This class should only be used in a multi-threaded environment.
Copyright: (c) 2002 The Open Math Company Limited
The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.
| Constructor Summary | |
CircularQueue(int size)
Constructs a new CircularQueue instance. |
|
| Method Summary | |
Object |
get()
Removes an element from the front of the queue. |
boolean |
isEmpty()
Returns true if the queue is empty. |
void |
put(Object element)
Appends a new element on to the end of the queue. |
String |
toString()
Returns a String describing the queue. |
| Methods inherited from class java.lang.Object |
|
| Constructor Detail |
public CircularQueue(int size)
CircularQueue instance. The queue will be of the
given size. The size of the queue cannot be changed once it is
created.
size - the int size of the queue.| Method Detail |
public void put(Object element)
throws QueueOverflowException
put(Object)
throws a QueueOverflowException. If the element has been enqueued successfully,
put(Object) raises a notify() to the adjacent thread.
NOTE: In the case where an exception is raised, put(Object) actually has placed the
element on the queue - it is signaling that there is no room for further elements.
size - the int size of the queue.QueueOverflowException - An exception thrown if
the queue was full.public Object get()
get() waits until notified by put(Object).
WARNING: There is no timeout on the wait - thus, get() will wait forever if
nothing is placed on the queue.
Object that had been at the front of the queue.public boolean isEmpty()
true if the queue is empty.
This method is essential if the queue is being used in a single-threaded environment: in such
a case, it is essential to test whether there are any elements on the queue before doing a
get().
boolean reporting the state of the queue.public String toString()
String describing the queue.
toString in class ObjectString reporting the state of the queue.
|
OpMath | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||