|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.utils.queue.FIFOQueue
Provides non-blocking FIFO queue.
Maximum limit can be set for the total number of the queued elements. The queue elements
are returned by the get()
method in the First-In-First-Out order. The method
returns quickly without blocking the caller.
Thread-safety note:
The queue implementation is not thread-safe; it must be synchronized externally to allow
simultaneous access by multiple threads.
Constructor Summary | |
FIFOQueue()
Creates an empty FIFOQueue with no size limit. |
|
FIFOQueue(int size)
Creates an empty FIFOQueue with the given maximum size limit. |
Method Summary | |
boolean |
add(java.lang.Object object)
Adds the object to the queue. |
void |
clear()
Removes all objects from the queue. |
java.lang.Object |
get()
Returns an object from the queue. |
java.lang.Object |
peek()
Returns an object from the queue. |
int |
size()
Returns the queue size. |
java.lang.String |
toString()
Returns the queue statistics. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public FIFOQueue()
The queue capacity will grow as needed.
public FIFOQueue(int size)
The size argument must be greater than zero. The queue will have a fixed capacity given by the argument.
size
- the maximum queue size
java.lang.IllegalArgumentException
- if the size argument is zero or negativeMethod Detail |
public boolean add(java.lang.Object object)
Queue
The method returns false if the given object could not be added to the queue. A common reason may be that the queue have a fixed capacity and the current number of the queued objects has reached the size limit.
add
in interface Queue
object
- the object to be added to the queue
public java.lang.Object get()
Queue
The returned object is removed from the queue.
get
in interface Queue
public java.lang.Object peek()
Queue
The returned object remains in the queue.
peek
in interface Queue
public void clear()
Queue
clear
in interface Queue
public int size()
Queue
Returns the current number of the objects in the queue.
size
in interface Queue
public java.lang.String toString()
Returns the current/peak/total number of the queue elements.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |