SUMO - Simulation of Urban MObility

ROVehicleCont Class Reference

A container for vehicles sorted by their departure time. More...

#include <ROVehicleCont.h>

Inheritance diagram for ROVehicleCont:
NamedObjectCont< ROVehicle * >

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 std::map< std::string,
ROVehicle * > & 
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.

Detailed Description

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.


Constructor & Destructor Documentation

ROVehicleCont::ROVehicleCont ( )

Constructor.

Definition at line 48 of file ROVehicleCont.cpp.

ROVehicleCont::~ROVehicleCont ( )

Destructor.

Definition at line 51 of file ROVehicleCont.cpp.

ROVehicleCont::ROVehicleCont ( const ROVehicleCont &  src) [private]

Invalidated copy constructor.


Member Function Documentation

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.

Parameters:
[in]idThe id of the vehicle to add
[in]itemThe vehicle to add
Returns:
Whether the vehicle could be added
See also:
NamedObjectCont::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 175 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.

See also:
NamedObjectCont::clear

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.

Parameters:
[in]idThe id of the vehicle to remove
Returns:
Whether the vehicle could be removed
See also:
NamedObjectCont::erase

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

Parameters:
[in]idThe id of the item to retrieve
Returns:
The item stored under the given id, or 0 if no such item exists

Definition at line 109 of file NamedObjectCont.h.

const std::map<std::string, ROVehicle * >& NamedObjectCont< ROVehicle * >::getMyMap ( ) const [inline, inherited]

Definition at line 220 of file NamedObjectCont.h.

Referenced by rebuildSorted().

std::vector<ROVehicle * > NamedObjectCont< ROVehicle * >::getTempVector ( ) const [inline, inherited]

Definition at line 195 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.

Returns:
The vehicle that departs most early

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 208 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.

See also:
NamedObjectCont::clear

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.

Parameters:
[in]idThe id of the item to remove
Returns:
If the item could been removed (an item with the id was within the container before)

Definition at line 90 of file NamedObjectCont.h.

unsigned int NamedObjectCont< ROVehicle * >::size ( ) const [inline, inherited]

Returns the number of items within the container.

Returns:
The number of stored items

Definition at line 133 of file NamedObjectCont.h.

Referenced by getTopVehicle().


Field Documentation

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().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines