SUMO - Simulation of Urban MObility
|
A container for vehicles sorted by their departure time. More...
#include <ROVehicleCont.h>
Public Types | |
typedef std::map< std::string, ROVehicle * > | IDMap |
Definition of the key to pointer map type. | |
Public Member Functions | |
virtual bool | add (const std::string &id, ROVehicle *item) |
Adds a vehicle to the container. | |
const std::vector< ROVehicle * > & | buildAndGetStaticVector () const |
void | clear () |
Deletes all vehicles stored; clears the lists. | |
bool | erase (const std::string &id) |
Tries to remove (and delete) the named vehicle. | |
ROVehicle * | get (const std::string &id) const |
Retrieves an item. | |
const IDMap & | getMyMap () const |
std::vector< ROVehicle * > | getTempVector () const |
const ROVehicle * | getTopVehicle () const |
Returns the vehicle that departs most early. | |
void | insertIDs (std::vector< std::string > &into) const |
virtual bool | remove (const std::string &id) |
Removes an item. | |
ROVehicleCont () | |
Constructor. | |
unsigned int | size () const |
Returns the number of items within the container. | |
~ROVehicleCont () | |
Destructor. | |
Private Member Functions | |
ROVehicleCont & | operator= (const ROVehicleCont &src) |
Invalidated assignment operator. | |
void | rebuildSorted () |
Rebuild the internal, sorted list. | |
ROVehicleCont (const ROVehicleCont &src) | |
Invalidated copy constructor. | |
Private Attributes | |
std::priority_queue< ROVehicle *, std::vector< ROVehicle * > , ROVehicleByDepartureComperator > | mySorted |
The sorted vehicle list. |
A container for vehicles sorted by their departure time.
A map of vehicle-ids to the vehicles themselves. Besides the functionality implemented in NamedObjectCont, this class stores vehicles sorted by their departure time.
Definition at line 54 of file ROVehicleCont.h.
typedef std::map< std::string, ROVehicle * > NamedObjectCont< ROVehicle * >::IDMap [inherited] |
Definition of the key to pointer map type.
Definition at line 56 of file NamedObjectCont.h.
Constructor.
Definition at line 48 of file ROVehicleCont.cpp.
Destructor.
Definition at line 51 of file ROVehicleCont.cpp.
ROVehicleCont::ROVehicleCont | ( | const ROVehicleCont & | src | ) | [private] |
Invalidated copy constructor.
bool ROVehicleCont::add | ( | const std::string & | id, |
ROVehicle * | item | ||
) | [virtual] |
Adds a vehicle to the container.
Tries to add the vehicle to the container using NamedObjectCont::add. If this succeeds, the vehicle is also added to the internal sorted list of vehicles.
Returns the value from NamedObjectCont::add.
[in] | id | The id of the vehicle to add |
[in] | item | The vehicle to add |
Reimplemented from NamedObjectCont< ROVehicle * >.
Definition at line 64 of file ROVehicleCont.cpp.
References mySorted.
Referenced by RONet::addVehicle().
const std::vector<ROVehicle * >& NamedObjectCont< ROVehicle * >::buildAndGetStaticVector | ( | ) | const [inline, inherited] |
Definition at line 178 of file NamedObjectCont.h.
void ROVehicleCont::clear | ( | ) |
Deletes all vehicles stored; clears the lists.
Calls NamedObjectCont::clear and replaces the internal, sorted list by an empty one.
Reimplemented from NamedObjectCont< ROVehicle * >.
Definition at line 74 of file ROVehicleCont.cpp.
References mySorted.
Referenced by RONet::~RONet().
bool ROVehicleCont::erase | ( | const std::string & | id | ) |
Tries to remove (and delete) the named vehicle.
Calls NamedObjectCont::erase. If this succeeds, the vehicle is removed from the internal sorted list. This method takes care whether the vehicle to remove is the top-most one (the one with the earliest depart time). If not, the internal list is rebuild.
[in] | id | The id of the vehicle to remove |
Reimplemented from NamedObjectCont< ROVehicle * >.
Definition at line 81 of file ROVehicleCont.cpp.
References ROVehicle::getID(), getTopVehicle(), mySorted, and rebuildSorted().
Referenced by RONet::saveAndRemoveRoutesUntil().
ROVehicle * NamedObjectCont< ROVehicle * >::get | ( | const std::string & | id | ) | const [inline, inherited] |
Retrieves an item.
Returns 0 when no item with the given id is stored within the container
[in] | id | The id of the item to retrieve |
Definition at line 112 of file NamedObjectCont.h.
const IDMap& NamedObjectCont< ROVehicle * >::getMyMap | ( | ) | const [inline, inherited] |
Definition at line 223 of file NamedObjectCont.h.
Referenced by rebuildSorted().
std::vector<ROVehicle * > NamedObjectCont< ROVehicle * >::getTempVector | ( | ) | const [inline, inherited] |
Definition at line 198 of file NamedObjectCont.h.
const ROVehicle * ROVehicleCont::getTopVehicle | ( | ) | const |
Returns the vehicle that departs most early.
Returns the first vehicle from the internal list of sorted vehicles or 0 if this list is empty.
Definition at line 55 of file ROVehicleCont.cpp.
References mySorted, and NamedObjectCont< ROVehicle * >::size().
Referenced by erase(), and RONet::saveAndRemoveRoutesUntil().
void NamedObjectCont< ROVehicle * >::insertIDs | ( | std::vector< std::string > & | into | ) | const [inline, inherited] |
Definition at line 211 of file NamedObjectCont.h.
ROVehicleCont& ROVehicleCont::operator= | ( | const ROVehicleCont & | src | ) | [private] |
Invalidated assignment operator.
void ROVehicleCont::rebuildSorted | ( | ) | [private] |
Rebuild the internal, sorted list.
Rebuilds the internal, sorted list by clearing it, first, and then adding all vehicles stored.
Definition at line 97 of file ROVehicleCont.cpp.
References NamedObjectCont< ROVehicle * >::getMyMap(), and mySorted.
Referenced by erase().
virtual bool NamedObjectCont< ROVehicle * >::remove | ( | const std::string & | id | ) | [inline, virtual, inherited] |
Removes an item.
[in] | id | The id of the item to remove |
Definition at line 93 of file NamedObjectCont.h.
unsigned int NamedObjectCont< ROVehicle * >::size | ( | ) | const [inline, inherited] |
Returns the number of items within the container.
Definition at line 136 of file NamedObjectCont.h.
Referenced by getTopVehicle().
std::priority_queue<ROVehicle*, std::vector<ROVehicle*>, ROVehicleByDepartureComperator> ROVehicleCont::mySorted [mutable, private] |
The sorted vehicle list.
Definition at line 127 of file ROVehicleCont.h.
Referenced by add(), clear(), erase(), getTopVehicle(), and rebuildSorted().