VANET Simulator
 All Classes Functions Variables
Public Member Functions | Static Public Member Functions | List of all members
vanetsim.scenario.KnownVehiclesList Class Reference

Public Member Functions

 KnownVehiclesList ()
 
synchronized void updateVehicle (Vehicle vehicle, long ID, int x, int y, double speed, long sourceID, boolean isEncrypted, boolean isARSU)
 
void checkOutdatedVehicles ()
 
Vehicle findNearestVehicle (int vehicleX, int vehicleY, int destX, int destY, int maxDistance)
 
KnownVehicle[] getFirstKnownVehicle ()
 
int getSize ()
 
void clear ()
 

Static Public Member Functions

static void setTimePassed (int time)
 

Detailed Description

A list of all known vehicles which was discovered through beacons. In contrast to the KnownPenalties- class, an own class is used for storing the information about the vehicles. Although this means slightly more overhead, it should not be a big case and allows better extensibility.
A simple hash algorithm based on the vehicle ID is used to get better performance. The hash determines the corresponding linked list(beginnings of linked lists are found in head_). Known vehicles with the same hash are connected together through their next_ and previous_ values (see KnownVehicle-class).

Constructor & Destructor Documentation

vanetsim.scenario.KnownVehiclesList.KnownVehiclesList ( )
inline

Empty constructor.

Member Function Documentation

void vanetsim.scenario.KnownVehiclesList.checkOutdatedVehicles ( )
inline

Checks if a vehicle is too old so that it can be removed. Note that this function is not synchronized! You need to make sure that no other thread uses any function on this object at the same time!

void vanetsim.scenario.KnownVehiclesList.clear ( )
inline

Clears everything from this data structure.

Vehicle vanetsim.scenario.KnownVehiclesList.findNearestVehicle ( int  vehicleX,
int  vehicleY,
int  destX,
int  destY,
int  maxDistance 
)
inline

Finds the nearest known vehicle to a destination.

Parameters
vehicleXthe x coordinate of the calling vehicle
vehicleYthe y coordinate of the calling vehicle
destXthe x coordinate of the destination
destYthe y coordinate of the destination
maxDistancethe maximum distance the nearest vehicle max have from the calling vehicle
Returns
the nearest vehicle or null if the calling vehicle is the nearest
KnownVehicle [] vanetsim.scenario.KnownVehiclesList.getFirstKnownVehicle ( )
inline

Gets an hashed array with known vehicles (array length depends on the HASH_SIZE). You can iterate through all known vehicles by using getNext() until you get to a null element on all elements of this array

Returns
the array with known vehicles
int vanetsim.scenario.KnownVehiclesList.getSize ( )
inline

Gets the amount of known vehicles stored.

Returns
the size
static void vanetsim.scenario.KnownVehiclesList.setTimePassed ( int  time)
inlinestatic

Sets the time passed since simulation start.

Parameters
timethe new time in milliseconds
synchronized void vanetsim.scenario.KnownVehiclesList.updateVehicle ( Vehicle  vehicle,
long  ID,
int  x,
int  y,
double  speed,
long  sourceID,
boolean  isEncrypted,
boolean  isARSU 
)
inline

Update a vehicle or add it if it doesn't exist yet.

Parameters
vehiclea reference to the vehicle
IDthe ID of the vehicle
xthe x coordinate
ythe y coordinate
speedthe speed
sourceIDID of the source
isEncryptedif Beacon was encrypted
isARSUif Beacon was sent from an ARSU

The documentation for this class was generated from the following file: