|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vanetsim.scenario.KnownVehiclesList
public class KnownVehiclesList
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 Summary | |
---|---|
KnownVehiclesList()
Empty constructor. |
Method Summary | |
---|---|
void |
checkOutdatedVehicles()
Checks if a vehicle is too old so that it can be removed. |
void |
clear()
Clears everything from this data structure. |
Vehicle |
findNearestVehicle(int vehicleX,
int vehicleY,
int destX,
int destY,
int maxDistance)
Finds the nearest known vehicle to a destination. |
KnownVehicle[] |
getFirstKnownVehicle()
Gets an hashed array with known vehicles (array length depends on the HASH_SIZE). |
int |
getSize()
Gets the amount of known vehicles stored. |
static void |
setTimePassed(int time)
Sets the time passed since simulation start. |
void |
updateVehicle(Vehicle vehicle,
long ID,
int x,
int y,
double speed,
long sourceID,
boolean isEncrypted,
boolean isARSU)
Update a vehicle or add it if it doesn't exist yet. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KnownVehiclesList()
Method Detail |
---|
public void updateVehicle(Vehicle vehicle, long ID, int x, int y, double speed, long sourceID, boolean isEncrypted, boolean isARSU)
vehicle
- a reference to the vehicleID
- the ID of the vehiclex
- the x coordinatey
- the y coordinatespeed
- the speedsourceID
- ID of the sourceisEncrypted
- if Beacon was encryptedisARSU
- if Beacon was sent from an ARSUpublic void checkOutdatedVehicles()
public Vehicle findNearestVehicle(int vehicleX, int vehicleY, int destX, int destY, int maxDistance)
vehicleX
- the x coordinate of the calling vehiclevehicleY
- the y coordinate of the calling vehicledestX
- the x coordinate of the destinationdestY
- the y coordinate of the destinationmaxDistance
- the maximum distance the nearest vehicle max have from the calling vehicle
null
if the calling vehicle is the nearestpublic KnownVehicle[] getFirstKnownVehicle()
getNext()
until you get to a null
element on all
elements of this array
public int getSize()
public static void setTimePassed(int time)
time
- the new time in millisecondspublic void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |