SUMO - Simulation of Urban MObility

MSVehicleContainer Class Reference

#include <MSVehicleContainer.h>

Data Structures

class  DepartFinder
 Searches for the VehicleDepartureVector with the wished depart. More...
class  VehicleDepartureVectorSortCrit
 Sort-criterion for vehicle departure lists. More...

Public Types

typedef std::pair< SUMOTime,
VehicleVector > 
VehicleDepartureVector
typedef std::vector
< SUMOVehicle * > 
VehicleVector
 definition of a list of vehicles which have the same departure time

Public Member Functions

void add (SUMOVehicle *veh)
 Adds a single vehicle.
void add (SUMOTime time, const VehicleVector &cont)
 Adds a container with vehicles departing at the given time.
bool anyWaitingFor (SUMOTime time) const
 Returns the information whether any vehicles want to depart at the given time.
bool isEmpty () const
 Returns the information whether the container is empty.
 MSVehicleContainer (size_t capacity=10)
 Constructor.
void pop ()
 Removes the uppermost vehicle vector.
void showArray () const
 Prints the container (the departure times)
size_t size () const
 Returns the size of the container.
const VehicleVector & top ()
 Returns the uppermost vehicle vector.
SUMOTime topTime () const
 Returns the time the uppermost vehicle vector is assigned to.
 ~MSVehicleContainer ()
 Destructor.

Private Types

typedef std::vector
< VehicleDepartureVector > 
VehicleHeap
 Definition of the heap type.

Private Member Functions

void addReplacing (const VehicleDepartureVector &cont)
 Replaces the existing single departure time vector by the one given.
bool isFull () const
void percolateDown (int hole)
 Moves the elements down.

Private Attributes

VehicleHeap array
 The vehicle vector heap.
int currentSize
 Number of elements in heap.

Friends

std::ostream & operator<< (std::ostream &strm, MSVehicleContainer &cont)
 Prints the contents of the container.

Detailed Description

A storage for vehicles, mainly used by the vehicle/route loading structures and the insertion control. Stores vehicles in a heap of vehiclevector/departure- pairs.

Definition at line 52 of file MSVehicleContainer.h.


Member Typedef Documentation

definition of a structure storing the departure time and a list of vehicles leaving at this time

Definition at line 59 of file MSVehicleContainer.h.

Definition of the heap type.

Definition at line 133 of file MSVehicleContainer.h.

definition of a list of vehicles which have the same departure time

Definition at line 55 of file MSVehicleContainer.h.


Constructor & Destructor Documentation

MSVehicleContainer::MSVehicleContainer ( size_t  capacity = 10)

Constructor.

Definition at line 73 of file MSVehicleContainer.cpp.

MSVehicleContainer::~MSVehicleContainer ( )

Destructor.

Definition at line 77 of file MSVehicleContainer.cpp.


Member Function Documentation

void MSVehicleContainer::add ( SUMOVehicle *  veh)

Adds a single vehicle.

Definition at line 83 of file MSVehicleContainer.cpp.

References addReplacing(), array, currentSize, SUMOVehicleParameter::depart, and SUMOVehicle::getParameter().

void MSVehicleContainer::add ( SUMOTime  time,
const VehicleVector &  cont 
)

Adds a container with vehicles departing at the given time.

Definition at line 101 of file MSVehicleContainer.cpp.

References addReplacing(), array, and currentSize.

void MSVehicleContainer::addReplacing ( const VehicleDepartureVector &  cont) [private]

Replaces the existing single departure time vector by the one given.

Definition at line 119 of file MSVehicleContainer.cpp.

References array, currentSize, and isFull().

Referenced by add().

bool MSVehicleContainer::anyWaitingFor ( SUMOTime  time) const

Returns the information whether any vehicles want to depart at the given time.

Definition at line 141 of file MSVehicleContainer.cpp.

References array, and currentSize.

bool MSVehicleContainer::isEmpty ( ) const

Returns the information whether the container is empty.

Definition at line 183 of file MSVehicleContainer.cpp.

References currentSize.

Referenced by operator<<(), pop(), top(), and topTime().

bool MSVehicleContainer::isFull ( ) const [private]

Returns the information whether the container must be extended

Definition at line 189 of file MSVehicleContainer.cpp.

References array, and currentSize.

Referenced by addReplacing().

void MSVehicleContainer::percolateDown ( int  hole) [private]

Moves the elements down.

Definition at line 195 of file MSVehicleContainer.cpp.

References array, and currentSize.

Referenced by pop().

void MSVehicleContainer::pop ( )

Removes the uppermost vehicle vector.

!!Underflow( );

Definition at line 169 of file MSVehicleContainer.cpp.

References array, currentSize, isEmpty(), and percolateDown().

Referenced by operator<<().

void MSVehicleContainer::showArray ( ) const

Prints the container (the departure times)

Definition at line 224 of file MSVehicleContainer.cpp.

References array, and currentSize.

size_t MSVehicleContainer::size ( ) const

Returns the size of the container.

Definition at line 218 of file MSVehicleContainer.cpp.

References currentSize.

const MSVehicleContainer::VehicleVector & MSVehicleContainer::top ( )

Returns the uppermost vehicle vector.

!!Underflow( );

Definition at line 149 of file MSVehicleContainer.cpp.

References array, and isEmpty().

Referenced by operator<<().

SUMOTime MSVehicleContainer::topTime ( ) const

Returns the time the uppermost vehicle vector is assigned to.

!!Underflow( );

Definition at line 159 of file MSVehicleContainer.cpp.

References array, and isEmpty().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  strm,
MSVehicleContainer &  cont 
) [friend]

Prints the contents of the container.

Definition at line 235 of file MSVehicleContainer.cpp.


Field Documentation

The vehicle vector heap.

Definition at line 136 of file MSVehicleContainer.h.

Referenced by add(), addReplacing(), anyWaitingFor(), isFull(), percolateDown(), pop(), showArray(), top(), and topTime().

Number of elements in heap.

Definition at line 130 of file MSVehicleContainer.h.

Referenced by add(), addReplacing(), anyWaitingFor(), isEmpty(), isFull(), percolateDown(), pop(), showArray(), and size().


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