TSim
Class SynchronizedSensorVector
java.lang.Object
|
+--TSim.SynchronizedSensorVector
- public class SynchronizedSensorVector
- extends java.lang.Object
Every train has an FIFO of sensor events associated with it. This FIFO
contains the sensor events of that specific train. Since we do not know
how many trains a specific line/run might have we need to allocate those
FIFOs dynamically. This is a synchronized helper class that does
just that. If the requested train has never been seen before a new empty
FIFO is allocated and returned.
Field Summary |
protected java.util.Vector |
vect
|
Constructor Summary |
SynchronizedSensorVector(int initialSize)
Creates a new SynchronizedSensorVector with the given initial size. |
Method Summary |
SynchronizedFIFO |
get(int index)
Returns the FIFO associated with a specific train and allocates
a new FIFO and expands the vector if it was the first request
for that train id. |
void |
put(int index,
SynchronizedFIFO o)
Stores the given FIFO at the specified position in the vector. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
vect
protected java.util.Vector vect
SynchronizedSensorVector
public SynchronizedSensorVector(int initialSize)
- Creates a new SynchronizedSensorVector with the given initial size.
- Parameters:
initialSize
- the initial size if the vector.
get
public SynchronizedFIFO get(int index)
- Returns the FIFO associated with a specific train and allocates
a new FIFO and expands the vector if it was the first request
for that train id.
- Parameters:
index
- the id of the train associated with the FIFO.- Returns:
- the FIFO associated with the train id.
put
public void put(int index,
SynchronizedFIFO o)
- Stores the given FIFO at the specified position in the vector.
The vector is expanded if needed.
- Parameters:
index
- the position where the FIFO should be placed.