|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.actor.util.FIFOQueue
public class FIFOQueue
A first-in, first-out (FIFO) queue with variable capacity and optional history. Objects are appended to the queue with the put() method, and removed from the queue with the take() method. The object removed is the oldest one in the queue. By default, the capacity is infinite, but it can be set to any nonnegative size. If the history capacity is greater than zero (or infinite, by setting the capacity to INFINITE_CAPACITY), then objects removed from the queue are transferred to a history queue rather than simply removed. By default, the history capacity is zero.
Green (liuj) |
Green (eal) |
Field Summary | |
---|---|
private Nameable |
_container
|
private int |
_historyCapacity
|
private java.util.LinkedList |
_historyList
|
private int |
_queueCapacity
|
private java.util.LinkedList |
_queueList
|
static int |
INFINITE_CAPACITY
Used to indicate that the size of the queue or the history queue is infinite. |
Constructor Summary | |
---|---|
FIFOQueue()
Construct an empty queue with no container. |
|
FIFOQueue(FIFOQueue model)
Copy constructor. |
|
FIFOQueue(Nameable container)
Construct an empty queue with the specified container. |
Method Summary | |
---|---|
void |
clear()
Remove all items currently stored in the queue and clear the history queue. |
java.lang.Object |
clone()
Clone this queue. |
java.util.List |
elementList()
List the objects in the queue, beginning with the oldest. |
java.util.Enumeration |
elements()
Deprecated. Used elementList() instead. |
java.lang.Object |
get(int offset)
Return an object in the queue or history. |
int |
getCapacity()
Return the queue capacity, or INFINITE_CAPACITY if it is unbounded. |
Nameable |
getContainer()
Return the container of the queue, or null if there is none. |
int |
getHistoryCapacity()
Return the capacity of the history queue. |
java.util.List |
historyElementList()
List the objects in the history, which are the N most recent objects taken from the queue, beginning with the oldest, where N is less than or equal to the history capacity. |
java.util.Enumeration |
historyElements()
Deprecated. Use historyElementList() instead. |
int |
historySize()
Return the number of objects in the history. |
boolean |
isFull()
Return true if the number of objects in the queue equals the queue capacity. |
boolean |
put(java.lang.Object element)
Put an object in the queue and return true if this will not cause the capacity to be exceeded. |
void |
setCapacity(int capacity)
Set queue capacity. |
void |
setContainer(Nameable container)
Set the container of the queue. |
void |
setHistoryCapacity(int capacity)
Set the capacity of the history queue. |
int |
size()
Return the number of objects in the queue. |
java.lang.Object |
take()
Remove the oldest object from the queue and return it. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INFINITE_CAPACITY
private Nameable _container
private int _queueCapacity
private java.util.LinkedList _queueList
private int _historyCapacity
private java.util.LinkedList _historyList
Constructor Detail |
---|
public FIFOQueue()
public FIFOQueue(Nameable container)
container
- The container of the queue.public FIFOQueue(FIFOQueue model)
model
- The queue to be copied.Method Detail |
---|
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.util.List elementList()
public java.util.Enumeration elements()
public java.lang.Object get(int offset) throws java.util.NoSuchElementException
offset
- The position of the desired object.
java.util.NoSuchElementException
- If the offset is out of range.public int getCapacity()
setCapacity(int)
public Nameable getContainer()
setContainer(ptolemy.kernel.util.Nameable)
public int getHistoryCapacity()
setHistoryCapacity(int)
public java.util.List historyElementList()
public java.util.Enumeration historyElements()
public int historySize()
public boolean isFull()
public boolean put(java.lang.Object element)
element
- An object to be put in the queue.
public void setCapacity(int capacity) throws IllegalActionException
capacity
- The desired capacity.
IllegalActionException
- If the queue contains more
objects than the proposed capacity or the proposed capacity
is illegal.getCapacity()
public void setContainer(Nameable container)
container
- The container of this queue.getContainer()
public void setHistoryCapacity(int capacity) throws IllegalActionException
capacity
- The desired capacity of the history queue.
IllegalActionException
- If the desired capacity
is illegal.getHistoryCapacity()
public int size()
public java.lang.Object take() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- If the queue is empty.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |