TSim
Class SynchronizedTrainEventVector

java.lang.Object
  |
  +--TSim.SynchronizedTrainEventVector

public class SynchronizedTrainEventVector
extends java.lang.Object

Associated with every train is a position in a vector consisting of the last error event of that particular train. This makes it possible to not only report the error on the standard error but also make future commands affecting the train result in an exception. Since the number of trains used in the line/run is not known such a vector need to expand dynamically. This class is a helper class that does just that.


Field Summary
protected  java.util.Vector vect
           
 
Constructor Summary
SynchronizedTrainEventVector(int initialSize)
          Creates a new SynchronizedTrainEventVector with the specified initial size.
 
Method Summary
 TrainEvent get(int index)
          Get the last event for the train represented by the id.
 void put(int index, TrainEvent e)
          Store the given train event for the specified train.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vect

protected java.util.Vector vect
Constructor Detail

SynchronizedTrainEventVector

public SynchronizedTrainEventVector(int initialSize)
Creates a new SynchronizedTrainEventVector with the specified initial size.
Parameters:
initialSize - the initial size of the vecort.
Method Detail

get

public TrainEvent get(int index)
Get the last event for the train represented by the id. The vector is expanded if necessary.
Parameters:
index - the id of the train.
Returns:
the last event of the train or null if no events were stored.

put

public void put(int index,
                TrainEvent e)
Store the given train event for the specified train. The vector is expanded if necessary.
Parameters:
index - the train id of the train associated with the event.
e - the train event.